Skip to content

Commit 081c4ee

Browse files
committed
free old scan_state->cur_plans, more comments
1 parent 6e7a516 commit 081c4ee

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

pickyappend.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ typedef struct
2424
} PreservedPlanState;
2525

2626

27+
static void
28+
free_child_scan_common_array(ChildScanCommon *cur_plans, int n)
29+
{
30+
int i;
31+
32+
if (!cur_plans)
33+
return;
34+
35+
/* We shouldn't free inner objects e.g. Plans here */
36+
for (i = 0; i < n; i++)
37+
pfree(cur_plans[i]);
38+
39+
pfree(cur_plans);
40+
}
41+
2742
static void
2843
clear_plan_states(PickyAppendState *scan_state)
2944
{
@@ -286,8 +301,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
286301
IsA(innerrel->cheapest_total_path, AppendPath) &&
287302
(inner_prel = get_pathman_relation_info(inner_entry->relid, NULL)))
288303
{
289-
elog(LOG, "adding new path !!!");
290-
//pprint(innerrel->cheapest_total_path);
304+
elog(LOG, "adding new nestloop path with pickyappend");
291305
}
292306
else return;
293307

@@ -496,12 +510,15 @@ pickyappend_rescan(CustomScanState *node)
496510

497511
parts = get_partition_oids(ranges, &nparts, prel);
498512

513+
/* Select new plans for this pass */
514+
free_child_scan_common_array(scan_state->cur_plans, scan_state->ncur_plans);
499515
scan_state->cur_plans = select_required_plans(scan_state->children,
500516
scan_state->nchildren,
501517
parts, nparts,
502518
&scan_state->ncur_plans);
503519
pfree(parts);
504520

521+
/* Transform selected plans into executable plan states */
505522
transform_plans_into_states(scan_state,
506523
scan_state->cur_plans,
507524
scan_state->ncur_plans,

pickyappend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ typedef struct
4545
List *custom_exprs;
4646
List *custom_expr_states;
4747

48+
/* All available plans */
4849
ChildScanCommon *children;
4950
int nchildren;
5051

52+
/* Currently selected plans \ plan states */
5153
ChildScanCommon *cur_plans;
5254
int ncur_plans;
55+
56+
/* Index of the selected plan state */
5357
int running_idx;
5458

59+
/* Contains reusable PlanStates */
5560
HTAB *plan_state_table;
5661
HASHCTL plan_state_table_config;
5762
} PickyAppendState;

0 commit comments

Comments
 (0)