Commit ed93b381 authored by osku's avatar osku

Since the function definitions in pars_info_t are accessed after pars_sql()

returns in the query graph execution stage, we can't free pars_info_t in
pars_sql(). Instead, make pars_sql() transfer ownership of pars_info_t to
the created query graph, and make que_graph_free() free it if needed.
parent 0bc37030
...@@ -547,9 +547,8 @@ struct pars_info_struct { ...@@ -547,9 +547,8 @@ struct pars_info_struct {
ib_vector* bound_lits; /* bound literals, or NULL ib_vector* bound_lits; /* bound literals, or NULL
(pars_bound_lit_t*) */ (pars_bound_lit_t*) */
ibool pars_sql_owns_us; ibool graph_owns_us; /* if TRUE (which is the default),
/* if TRUE (which is the default), que_graph_free() will free us */
pars_sql() free us before exiting */
}; };
/* User-supplied function and argument. */ /* User-supplied function and argument. */
......
...@@ -397,6 +397,7 @@ struct que_fork_struct{ ...@@ -397,6 +397,7 @@ struct que_fork_struct{
sym_tab_t* sym_tab; /* symbol table of the query, sym_tab_t* sym_tab; /* symbol table of the query,
generated by the parser, or NULL generated by the parser, or NULL
if the graph was created 'by hand' */ if the graph was created 'by hand' */
pars_info_t* info; /* in: info struct, or NULL */
/* The following cur_... fields are relevant only in a select graph */ /* The following cur_... fields are relevant only in a select graph */
ulint cur_end; /* QUE_CUR_NOT_DEFINED, QUE_CUR_START, ulint cur_end; /* QUE_CUR_NOT_DEFINED, QUE_CUR_START,
......
...@@ -1875,13 +1875,10 @@ pars_sql( ...@@ -1875,13 +1875,10 @@ pars_sql(
graph = pars_sym_tab_global->query_graph; graph = pars_sym_tab_global->query_graph;
graph->sym_tab = pars_sym_tab_global; graph->sym_tab = pars_sym_tab_global;
graph->info = info;
/* fprintf(stderr, "SQL graph size %lu\n", mem_heap_get_size(heap)); */ /* fprintf(stderr, "SQL graph size %lu\n", mem_heap_get_size(heap)); */
if (info && info->pars_sql_owns_us) {
pars_info_free(info);
}
return(graph); return(graph);
} }
...@@ -1934,7 +1931,7 @@ pars_info_create(void) ...@@ -1934,7 +1931,7 @@ pars_info_create(void)
info->heap = heap; info->heap = heap;
info->funcs = NULL; info->funcs = NULL;
info->bound_lits = NULL; info->bound_lits = NULL;
info->pars_sql_owns_us = TRUE; info->graph_owns_us = TRUE;
return(info); return(info);
} }
......
...@@ -172,6 +172,7 @@ que_fork_create( ...@@ -172,6 +172,7 @@ que_fork_create(
UT_LIST_INIT(fork->thrs); UT_LIST_INIT(fork->thrs);
fork->sym_tab = NULL; fork->sym_tab = NULL;
fork->info = NULL;
fork->heap = heap; fork->heap = heap;
...@@ -671,6 +672,10 @@ que_graph_free( ...@@ -671,6 +672,10 @@ que_graph_free(
sym_tab_free_private(graph->sym_tab); sym_tab_free_private(graph->sym_tab);
} }
if (graph->info && graph->info->graph_owns_us) {
pars_info_free(graph->info);
}
que_graph_free_recursive(graph); que_graph_free_recursive(graph);
mem_heap_free(graph->heap); mem_heap_free(graph->heap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment