Skip to content

Commit add67fa

Browse files
committed
make use of RegisterCustomScanMethods(), rename some runtime* funcs and files
1 parent 14d15f2 commit add67fa

10 files changed

+112
-100
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
MODULE_big = pg_pathman
44

55
OBJS = src/init.o src/relation_info.o src/utils.o src/partition_filter.o \
6-
src/runtimeappend.o src/runtime_merge_append.o src/pg_pathman.o src/rangeset.o \
6+
src/runtime_append.o src/runtime_merge_append.o src/pg_pathman.o src/rangeset.o \
77
src/pl_funcs.o src/pl_range_funcs.o src/pl_hash_funcs.o src/pathman_workers.o \
88
src/hooks.o src/nodes_common.o src/xact_handling.o src/utility_stmt_hooking.o \
99
src/planner_tree_modification.o src/debug_print.o src/partition_creation.o \

Diff for: src/hooks.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "partition_router.h"
2020
#include "pathman_workers.h"
2121
#include "planner_tree_modification.h"
22-
#include "runtimeappend.h"
22+
#include "runtime_append.h"
2323
#include "runtime_merge_append.h"
2424
#include "utility_stmt_hooking.h"
2525
#include "utils.h"
@@ -244,7 +244,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
244244
continue;
245245

246246
/* Try building RuntimeAppend path, skip if it's not possible */
247-
inner = create_runtimeappend_path(root, cur_inner_path, ppi, paramsel);
247+
inner = create_runtime_append_path(root, cur_inner_path, ppi, paramsel);
248248
if (!inner)
249249
continue;
250250

@@ -549,8 +549,8 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
549549
ppi = get_appendrel_parampathinfo(rel, inner_required);
550550

551551
if (IsA(cur_path, AppendPath) && pg_pathman_enable_runtimeappend)
552-
inner_path = create_runtimeappend_path(root, cur_path,
553-
ppi, paramsel);
552+
inner_path = create_runtime_append_path(root, cur_path,
553+
ppi, paramsel);
554554
else if (IsA(cur_path, MergeAppendPath) &&
555555
pg_pathman_enable_runtime_merge_append)
556556
{
@@ -560,8 +560,8 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
560560
elog(FATAL, "Struct layouts of AppendPath and "
561561
"MergeAppendPath differ");
562562

563-
inner_path = create_runtimemergeappend_path(root, cur_path,
564-
ppi, paramsel);
563+
inner_path = create_runtime_merge_append_path(root, cur_path,
564+
ppi, paramsel);
565565
}
566566

567567
if (inner_path)

Diff for: src/include/runtimeappend.h renamed to src/include/runtime_append.h

+21-18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include "commands/explain.h"
2222

2323

24+
#define RUNTIME_APPEND_NODE_NAME "RuntimeAppend"
25+
26+
2427
typedef struct
2528
{
2629
CustomPath cpath;
@@ -70,32 +73,32 @@ extern CustomScanMethods runtimeappend_plan_methods;
7073
extern CustomExecMethods runtimeappend_exec_methods;
7174

7275

73-
void init_runtimeappend_static_data(void);
76+
void init_runtime_append_static_data(void);
7477

75-
Path * create_runtimeappend_path(PlannerInfo *root,
76-
AppendPath *inner_append,
77-
ParamPathInfo *param_info,
78-
double sel);
78+
Path * create_runtime_append_path(PlannerInfo *root,
79+
AppendPath *inner_append,
80+
ParamPathInfo *param_info,
81+
double sel);
7982

80-
Plan * create_runtimeappend_plan(PlannerInfo *root, RelOptInfo *rel,
81-
CustomPath *best_path, List *tlist,
82-
List *clauses, List *custom_plans);
83+
Plan * create_runtime_append_plan(PlannerInfo *root, RelOptInfo *rel,
84+
CustomPath *best_path, List *tlist,
85+
List *clauses, List *custom_plans);
8386

84-
Node * runtimeappend_create_scan_state(CustomScan *node);
87+
Node * runtime_append_create_scan_state(CustomScan *node);
8588

86-
void runtimeappend_begin(CustomScanState *node,
87-
EState *estate,
88-
int eflags);
89+
void runtime_append_begin(CustomScanState *node,
90+
EState *estate,
91+
int eflags);
8992

90-
TupleTableSlot * runtimeappend_exec(CustomScanState *node);
93+
TupleTableSlot * runtime_append_exec(CustomScanState *node);
9194

92-
void runtimeappend_end(CustomScanState *node);
95+
void runtime_append_end(CustomScanState *node);
9396

94-
void runtimeappend_rescan(CustomScanState *node);
97+
void runtime_append_rescan(CustomScanState *node);
9598

96-
void runtimeappend_explain(CustomScanState *node,
97-
List *ancestors,
98-
ExplainState *es);
99+
void runtime_append_explain(CustomScanState *node,
100+
List *ancestors,
101+
ExplainState *es);
99102

100103

101104
#endif /* RUNTIME_APPEND_H */

Diff for: src/include/runtime_merge_append.h

+21-18
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
#define RUNTIME_MERGE_APPEND_H
1515

1616

17-
#include "runtimeappend.h"
17+
#include "runtime_append.h"
1818
#include "pathman.h"
1919

2020
#include "postgres.h"
2121

2222

23+
#define RUNTIME_MERGE_APPEND_NODE_NAME "RuntimeMergeAppend"
24+
25+
2326
typedef struct
2427
{
2528
RuntimeAppendPath rpath;
@@ -54,30 +57,30 @@ extern CustomExecMethods runtime_merge_append_exec_methods;
5457

5558
void init_runtime_merge_append_static_data(void);
5659

57-
Path * create_runtimemergeappend_path(PlannerInfo *root,
58-
AppendPath *inner_append,
59-
ParamPathInfo *param_info,
60-
double sel);
60+
Path * create_runtime_merge_append_path(PlannerInfo *root,
61+
AppendPath *inner_append,
62+
ParamPathInfo *param_info,
63+
double sel);
6164

62-
Plan * create_runtimemergeappend_plan(PlannerInfo *root, RelOptInfo *rel,
63-
CustomPath *best_path, List *tlist,
64-
List *clauses, List *custom_plans);
65+
Plan * create_runtime_merge_append_plan(PlannerInfo *root, RelOptInfo *rel,
66+
CustomPath *best_path, List *tlist,
67+
List *clauses, List *custom_plans);
6568

66-
Node * runtimemergeappend_create_scan_state(CustomScan *node);
69+
Node * runtime_merge_append_create_scan_state(CustomScan *node);
6770

68-
void runtimemergeappend_begin(CustomScanState *node,
69-
EState *estate,
70-
int eflags);
71+
void runtime_merge_append_begin(CustomScanState *node,
72+
EState *estate,
73+
int eflags);
7174

72-
TupleTableSlot * runtimemergeappend_exec(CustomScanState *node);
75+
TupleTableSlot * runtime_merge_append_exec(CustomScanState *node);
7376

74-
void runtimemergeappend_end(CustomScanState *node);
77+
void runtime_merge_append_end(CustomScanState *node);
7578

76-
void runtimemergeappend_rescan(CustomScanState *node);
79+
void runtime_merge_append_rescan(CustomScanState *node);
7780

78-
void runtimemergeappend_explain(CustomScanState *node,
79-
List *ancestors,
80-
ExplainState *es);
81+
void runtime_merge_append_explain(CustomScanState *node,
82+
List *ancestors,
83+
ExplainState *es);
8184

8285

8386
#endif /* RUNTIME_MERGE_APPEND_H */

Diff for: src/nodes_common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "init.h"
1313
#include "nodes_common.h"
14-
#include "runtimeappend.h"
14+
#include "runtime_append.h"
1515
#include "utils.h"
1616

1717
#include "nodes/nodeFuncs.h"

Diff for: src/partition_filter.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ init_partition_filter_static_data(void)
131131
NULL,
132132
NULL,
133133
NULL);
134+
135+
RegisterCustomScanMethods(&partition_filter_plan_methods);
134136
}
135137

136138

@@ -659,12 +661,10 @@ partition_filter_begin(CustomScanState *node, EState *estate, int eflags)
659661
{
660662
PartitionFilterState *state = (PartitionFilterState *) node;
661663
Oid parent_relid = state->partitioned_table;
662-
PlanState *child_state;
663664
ResultRelInfo *current_rri;
664665

665666
/* It's convenient to store PlanState in 'custom_ps' */
666-
child_state = ExecInitNode(state->subplan, estate, eflags);
667-
node->custom_ps = list_make1(child_state);
667+
node->custom_ps = list_make1(ExecInitNode(state->subplan, estate, eflags));
668668

669669
/* Fetch current result relation (rri + rel) */
670670
current_rri = estate->es_result_relation_info;

Diff for: src/partition_router.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ init_partition_router_static_data(void)
5858
NULL,
5959
NULL,
6060
NULL);
61+
62+
RegisterCustomScanMethods(&partition_router_plan_methods);
6163
}
6264

6365
Plan *
@@ -121,7 +123,7 @@ partition_router_begin(CustomScanState *node, EState *estate, int eflags)
121123
{
122124
PartitionRouterState *state = (PartitionRouterState *) node;
123125

124-
/* Initialize PartitionFilter child node */
126+
/* It's convenient to store PlanState in 'custom_ps' */
125127
node->custom_ps = list_make1(ExecInitNode(state->subplan, estate, eflags));
126128
}
127129

Diff for: src/pg_pathman.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "partition_filter.h"
1919
#include "partition_router.h"
2020
#include "planner_tree_modification.h"
21-
#include "runtimeappend.h"
21+
#include "runtime_append.h"
2222
#include "runtime_merge_append.h"
2323

2424
#include "postgres.h"
@@ -319,7 +319,7 @@ _PG_init(void)
319319
/* Initialize static data for all subsystems */
320320
init_main_pathman_toggles();
321321
init_relation_info_static_data();
322-
init_runtimeappend_static_data();
322+
init_runtime_append_static_data();
323323
init_runtime_merge_append_static_data();
324324
init_partition_filter_static_data();
325325
init_partition_router_static_data();

Diff for: src/runtimeappend.c renamed to src/runtime_append.c

+28-26
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* ------------------------------------------------------------------------
99
*/
1010

11-
#include "runtimeappend.h"
11+
#include "runtime_append.h"
1212

1313
#include "utils/guc.h"
1414

@@ -21,25 +21,25 @@ CustomExecMethods runtimeappend_exec_methods;
2121

2222

2323
void
24-
init_runtimeappend_static_data(void)
24+
init_runtime_append_static_data(void)
2525
{
26-
runtimeappend_path_methods.CustomName = "RuntimeAppend";
27-
runtimeappend_path_methods.PlanCustomPath = create_runtimeappend_plan;
26+
runtimeappend_path_methods.CustomName = RUNTIME_APPEND_NODE_NAME;
27+
runtimeappend_path_methods.PlanCustomPath = create_runtime_append_plan;
2828

29-
runtimeappend_plan_methods.CustomName = "RuntimeAppend";
30-
runtimeappend_plan_methods.CreateCustomScanState = runtimeappend_create_scan_state;
29+
runtimeappend_plan_methods.CustomName = RUNTIME_APPEND_NODE_NAME;
30+
runtimeappend_plan_methods.CreateCustomScanState = runtime_append_create_scan_state;
3131

32-
runtimeappend_exec_methods.CustomName = "RuntimeAppend";
33-
runtimeappend_exec_methods.BeginCustomScan = runtimeappend_begin;
34-
runtimeappend_exec_methods.ExecCustomScan = runtimeappend_exec;
35-
runtimeappend_exec_methods.EndCustomScan = runtimeappend_end;
36-
runtimeappend_exec_methods.ReScanCustomScan = runtimeappend_rescan;
32+
runtimeappend_exec_methods.CustomName = RUNTIME_APPEND_NODE_NAME;
33+
runtimeappend_exec_methods.BeginCustomScan = runtime_append_begin;
34+
runtimeappend_exec_methods.ExecCustomScan = runtime_append_exec;
35+
runtimeappend_exec_methods.EndCustomScan = runtime_append_end;
36+
runtimeappend_exec_methods.ReScanCustomScan = runtime_append_rescan;
3737
runtimeappend_exec_methods.MarkPosCustomScan = NULL;
3838
runtimeappend_exec_methods.RestrPosCustomScan = NULL;
39-
runtimeappend_exec_methods.ExplainCustomScan = runtimeappend_explain;
39+
runtimeappend_exec_methods.ExplainCustomScan = runtime_append_explain;
4040

4141
DefineCustomBoolVariable("pg_pathman.enable_runtimeappend",
42-
"Enables the planner's use of RuntimeAppend custom node.",
42+
"Enables the planner's use of " RUNTIME_APPEND_NODE_NAME " custom node.",
4343
NULL,
4444
&pg_pathman_enable_runtimeappend,
4545
true,
@@ -48,13 +48,15 @@ init_runtimeappend_static_data(void)
4848
NULL,
4949
NULL,
5050
NULL);
51+
52+
RegisterCustomScanMethods(&runtimeappend_plan_methods);
5153
}
5254

5355
Path *
54-
create_runtimeappend_path(PlannerInfo *root,
55-
AppendPath *inner_append,
56-
ParamPathInfo *param_info,
57-
double sel)
56+
create_runtime_append_path(PlannerInfo *root,
57+
AppendPath *inner_append,
58+
ParamPathInfo *param_info,
59+
double sel)
5860
{
5961
return create_append_path_common(root, inner_append,
6062
param_info,
@@ -64,9 +66,9 @@ create_runtimeappend_path(PlannerInfo *root,
6466
}
6567

6668
Plan *
67-
create_runtimeappend_plan(PlannerInfo *root, RelOptInfo *rel,
68-
CustomPath *best_path, List *tlist,
69-
List *clauses, List *custom_plans)
69+
create_runtime_append_plan(PlannerInfo *root, RelOptInfo *rel,
70+
CustomPath *best_path, List *tlist,
71+
List *clauses, List *custom_plans)
7072
{
7173
return create_append_plan_common(root, rel,
7274
best_path, tlist,
@@ -75,15 +77,15 @@ create_runtimeappend_plan(PlannerInfo *root, RelOptInfo *rel,
7577
}
7678

7779
Node *
78-
runtimeappend_create_scan_state(CustomScan *node)
80+
runtime_append_create_scan_state(CustomScan *node)
7981
{
8082
return create_append_scan_state_common(node,
8183
&runtimeappend_exec_methods,
8284
sizeof(RuntimeAppendState));
8385
}
8486

8587
void
86-
runtimeappend_begin(CustomScanState *node, EState *estate, int eflags)
88+
runtime_append_begin(CustomScanState *node, EState *estate, int eflags)
8789
{
8890
begin_append_common(node, estate, eflags);
8991
}
@@ -116,25 +118,25 @@ fetch_next_tuple(CustomScanState *node)
116118
}
117119

118120
TupleTableSlot *
119-
runtimeappend_exec(CustomScanState *node)
121+
runtime_append_exec(CustomScanState *node)
120122
{
121123
return exec_append_common(node, fetch_next_tuple);
122124
}
123125

124126
void
125-
runtimeappend_end(CustomScanState *node)
127+
runtime_append_end(CustomScanState *node)
126128
{
127129
end_append_common(node);
128130
}
129131

130132
void
131-
runtimeappend_rescan(CustomScanState *node)
133+
runtime_append_rescan(CustomScanState *node)
132134
{
133135
rescan_append_common(node);
134136
}
135137

136138
void
137-
runtimeappend_explain(CustomScanState *node, List *ancestors, ExplainState *es)
139+
runtime_append_explain(CustomScanState *node, List *ancestors, ExplainState *es)
138140
{
139141
RuntimeAppendState *scan_state = (RuntimeAppendState *) node;
140142

0 commit comments

Comments
 (0)