33
33
#include "utils/guc.h"
34
34
#include "utils/lsyscache.h"
35
35
#include "utils/selfuncs.h"
36
+ #include "utils/memutils.h"
36
37
#include "access/heapam.h"
37
38
#include "access/nbtree.h"
38
39
#include "storage/ipc.h"
@@ -266,8 +267,6 @@ pathman_post_parse_analysis_hook(ParseState *pstate, Query *query)
266
267
if (post_parse_analyze_hook_original )
267
268
post_parse_analyze_hook_original (pstate , query );
268
269
269
- // list_free(inheritance_disabled_relids);
270
- // list_free(inheritance_enabled_relids);
271
270
inheritance_disabled_relids = NIL ;
272
271
inheritance_enabled_relids = NIL ;
273
272
}
@@ -308,7 +307,9 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
308
307
result = standard_planner (parse , cursorOptions , boundParams );
309
308
310
309
list_free (inheritance_disabled_relids );
310
+ list_free (inheritance_enabled_relids );
311
311
inheritance_disabled_relids = NIL ;
312
+ inheritance_enabled_relids = NIL ;
312
313
313
314
return result ;
314
315
}
@@ -320,9 +321,10 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
320
321
static void
321
322
disable_inheritance (Query * parse )
322
323
{
323
- ListCell * lc ;
324
- RangeTblEntry * rte ;
325
- PartRelationInfo * prel ;
324
+ ListCell * lc ;
325
+ RangeTblEntry * rte ;
326
+ PartRelationInfo * prel ;
327
+ MemoryContext oldcontext ;
326
328
bool found ;
327
329
328
330
/* If query contains CTE (WITH statement) then handle subqueries too */
@@ -351,8 +353,10 @@ disable_inheritance(Query *parse)
351
353
* when user uses ONLY statement from case when we
352
354
* make rte->inh false intentionally.
353
355
*/
356
+ oldcontext = MemoryContextSwitchTo (TopMemoryContext );
354
357
inheritance_enabled_relids = \
355
358
lappend_oid (inheritance_enabled_relids , rte -> relid );
359
+ MemoryContextSwitchTo (oldcontext );
356
360
357
361
/*
358
362
* Check if relation was already found with ONLY modifier. In
@@ -367,8 +371,10 @@ disable_inheritance(Query *parse)
367
371
}
368
372
}
369
373
374
+ oldcontext = MemoryContextSwitchTo (TopMemoryContext );
370
375
inheritance_disabled_relids = \
371
376
lappend_oid (inheritance_disabled_relids , rte -> relid );
377
+ MemoryContextSwitchTo (oldcontext );
372
378
373
379
/* Check if relation was already found withoud ONLY modifier */
374
380
if (list_member_oid (inheritance_enabled_relids , rte -> relid ))
0 commit comments