Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b25335

Browse files
committed
no need for 'runtime_clauses' to be passed to create_path, simplify code, add GucBoolAssignHook
1 parent0fb9f6b commit4b25335

14 files changed

+39
-163
lines changed

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# contrib/pg_pathman/Makefile
22

33
MODULE_big = pg_pathman
4-
OBJS = init.outils.oruntimeappend.o runtime_merge_append.o pg_pathman.o dsm_array.o\
4+
OBJS = init.o runtimeappend.o runtime_merge_append.o pg_pathman.o dsm_array.o\
55
rangeset.o pl_funcs.o worker.o hooks.o nodes_common.o$(WIN32RES)
66

77
EXTENSION = pg_pathman

‎expected/pg_pathman.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ SELECT COUNT(*) FROM ONLY test.num_range_rel;
116116
0
117117
(1 row)
118118

119+
SET pg_pathman.enable_runtimeappend = OFF;
120+
SET pg_pathman.enable_runtimemergeappend = OFF;
119121
VACUUM;
120122
/* update triggers test */
121123
SELECT pathman.create_hash_update_trigger('test.hash_rel');
@@ -481,8 +483,6 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel_1 UNION ALL SELECT * FROM test.
481483
SET enable_hashjoin = OFF;
482484
set enable_nestloop = OFF;
483485
SET enable_mergejoin = ON;
484-
SET pg_pathman.enable_runtimeappend = OFF;
485-
SET pg_pathman.enable_runtimemergeappend = OFF;
486486
EXPLAIN (COSTS OFF)
487487
SELECT * FROM test.range_rel j1
488488
JOIN test.range_rel j2 on j2.id = j1.id
@@ -716,7 +716,7 @@ begin
716716
perform test.pathman_equal((plan->0->'Plan'->'Plans'->1->'Plans'->0->'Plans'->i->'Relation Name')::text,
717717
format('"runtime_test_2_%s"', i + 1),
718718
'wrong partition');
719-
719+
720720
num = plan->0->'Plan'->'Plans'->1->'Plans'->0->'Plans'->i->'Actual Loops';
721721
perform test.pathman_assert(num = 1, 'expected no more than 1 loops');
722722
end loop;

‎hooks.c

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include"postgres.h"
1111
#include"optimizer/cost.h"
1212
#include"optimizer/restrictinfo.h"
13+
#include"utils/guc.h"
1314
#include"hooks.h"
1415
#include"utils.h"
1516
#include"pathman.h"
@@ -106,7 +107,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
106107
inner=create_runtimeappend_path(root,cur_inner_path,
107108
get_appendrel_parampathinfo(innerrel,
108109
inner_required),
109-
joinclauses,paramsel);
110+
paramsel);
110111

111112
initial_cost_nestloop(root,&workspace,jointype,
112113
outer,inner,
@@ -262,7 +263,6 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
262263

263264
for (i=irange_lower(irange);i <=irange_upper(irange);i++)
264265
append_child_relation(root,rel,rti,rte,i,dsm_arr[i],wrappers);
265-
266266
}
267267

268268
/* Clear old path list */
@@ -282,8 +282,6 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
282282
Relidsinner_required=PATH_REQ_OUTER((Path*)cur_path);
283283
ParamPathInfo*ppi=get_appendrel_parampathinfo(rel,inner_required);
284284
Path*inner_path=NULL;
285-
ListCell*subpath_cell;
286-
List*runtime_quals=NIL;
287285

288286
if (!(IsA(cur_path,AppendPath)||IsA(cur_path,MergeAppendPath))||
289287
rel->has_eclass_joins||
@@ -292,56 +290,29 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
292290
continue;
293291
}
294292

295-
foreach (subpath_cell,cur_path->subpaths)
296-
{
297-
Path*subpath= (Path*)lfirst(subpath_cell);
298-
RelOptInfo*child_rel=subpath->parent;
299-
List*quals;
300-
ListCell*qual_cell;
301-
ReplaceVarsContextrepl_var_cxt;
302-
303-
repl_var_cxt.child=subpath->parent;
304-
repl_var_cxt.parent=rel;
305-
repl_var_cxt.sublevels_up=0;
306-
307-
quals=extract_actual_clauses(child_rel->baserestrictinfo, false);
308-
309-
/* Do not proceed if there's a rel containing quals without params */
310-
if (!clause_contains_params((Node*)quals))
311-
{
312-
runtime_quals=NIL;/* skip this path */
313-
break;
314-
}
315-
316-
/* Replace child Vars with a parent rel's Var */
317-
quals= (List*)replace_child_vars_with_parent_var((Node*)quals,
318-
&repl_var_cxt);
319-
320-
/* Combine unique quals for RuntimeAppend */
321-
foreach (qual_cell,quals)
322-
runtime_quals=list_append_unique(runtime_quals,
323-
(Node*)lfirst(qual_cell));
324-
}
325-
326-
/*
327-
* Dismiss RuntimeAppend if there
328-
* are no parameterized quals
329-
*/
330-
if (runtime_quals==NIL)
331-
continue;
332-
333293
if (IsA(cur_path,AppendPath)&&pg_pathman_enable_runtimeappend)
334294
inner_path=create_runtimeappend_path(root,cur_path,
335-
ppi,runtime_quals,
336-
paramsel);
295+
ppi,paramsel);
337296
elseif (IsA(cur_path,MergeAppendPath)&&
338297
pg_pathman_enable_runtime_merge_append)
339298
inner_path=create_runtimemergeappend_path(root,cur_path,
340-
ppi,runtime_quals,
341-
paramsel);
299+
ppi,paramsel);
342300

343301
if (inner_path)
344302
add_path(rel,inner_path);
345303
}
346304
}
347305
}
306+
307+
voidpg_pathman_enable_assign_hook(boolnewval,void*extra)
308+
{
309+
if (pg_pathman_enable==newval)
310+
return;
311+
312+
pg_pathman_enable_runtime_merge_append=newval;
313+
pg_pathman_enable_runtimeappend=newval;
314+
315+
elog(NOTICE,
316+
"RuntimeAppend and RuntimeMergeAppend nodes have been %s",
317+
newval ?"enabled" :"disabled");
318+
}

‎hooks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ void pathman_join_pathlist_hook(PlannerInfo *root, RelOptInfo *joinrel, RelOptIn
2121

2222
voidpathman_rel_pathlist_hook(PlannerInfo*root,RelOptInfo*rel,Indexrti,RangeTblEntry*rte);
2323

24+
voidpg_pathman_enable_assign_hook(charnewval,void*extra);
25+
2426
#endif

‎nodes_common.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include"optimizer/paths.h"
1212
#include"nodes_common.h"
1313
#include"runtimeappend.h"
14+
#include"optimizer/restrictinfo.h"
1415

1516

1617

@@ -203,7 +204,6 @@ Path *
203204
create_append_path_common(PlannerInfo*root,
204205
AppendPath*inner_append,
205206
ParamPathInfo*param_info,
206-
List*runtime_clauses,
207207
CustomPathMethods*path_methods,
208208
uint32size,
209209
doublesel)
@@ -234,10 +234,6 @@ create_append_path_common(PlannerInfo *root,
234234
result->cpath.path.startup_cost=0.0;
235235
result->cpath.path.total_cost=0.0;
236236

237-
/* Set 'partitioned column'-related clauses */
238-
result->cpath.custom_private=runtime_clauses;
239-
result->cpath.custom_paths=NIL;
240-
241237
Assert(inner_entry->relid!=0);
242238
result->relid=inner_entry->relid;
243239

@@ -286,7 +282,7 @@ create_append_plan_common(PlannerInfo *root, RelOptInfo *rel,
286282
cscan->custom_scan_tlist=tlist;
287283
cscan->scan.scanrelid=0;
288284

289-
cscan->custom_exprs=gpath->cpath.custom_private;
285+
cscan->custom_exprs=get_actual_clauses(clauses);
290286
cscan->custom_plans=custom_plans;
291287

292288
cscan->methods=scan_methods;

‎nodes_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ clear_plan_states(CustomScanState *scan_state)
6363
Path*create_append_path_common(PlannerInfo*root,
6464
AppendPath*inner_append,
6565
ParamPathInfo*param_info,
66-
List*runtime_clauses,
6766
CustomPathMethods*path_methods,
6867
uint32size,
6968
doublesel);

‎pg_pathman.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ _PG_init(void)
198198
PGC_USERSET,
199199
0,
200200
NULL,
201-
NULL,
201+
pg_pathman_enable_assign_hook,
202202
NULL);
203203

204204
DefineCustomBoolVariable("pg_pathman.enable_runtimeappend",
@@ -1357,7 +1357,7 @@ handle_boolexpr(const BoolExpr *expr, WalkerContext *context)
13571357
foreach (lc,expr->args)
13581358
{
13591359
WrapperNode*arg;
1360-
1360+
13611361
arg=walk_expr_tree((Expr*)lfirst(lc),context);
13621362
result->args=lappend(result->args,arg);
13631363
switch (expr->boolop)

‎runtime_merge_append.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,16 @@ unpack_runtimemergeappend_private(RuntimeMergeAppendState *scan_state,
171171

172172
Path*
173173
create_runtimemergeappend_path(PlannerInfo*root,
174-
AppendPath*inner_append,
175-
ParamPathInfo*param_info,
176-
List*picky_clauses,doublesel)
174+
AppendPath*inner_append,
175+
ParamPathInfo*param_info,
176+
doublesel)
177177
{
178178
RelOptInfo*rel=inner_append->path.parent;
179179
Path*path;
180180
doublelimit_tuples;
181181

182182
path=create_append_path_common(root,inner_append,
183-
param_info,picky_clauses,
183+
param_info,
184184
&runtime_merge_append_path_methods,
185185
sizeof(RuntimeMergeAppendPath),
186186
sel);

‎runtime_merge_append.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern CustomExecMethodsruntime_merge_append_exec_methods;
5050

5151

5252
Path*create_runtimemergeappend_path(PlannerInfo*root,AppendPath*inner_append,
53-
ParamPathInfo*param_info,List*runtime_clauses,
53+
ParamPathInfo*param_info,
5454
doublesel);
5555

5656
Plan*create_runtimemergeappend_plan(PlannerInfo*root,RelOptInfo*rel,

‎runtimeappend.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ Path *
2424
create_runtimeappend_path(PlannerInfo*root,
2525
AppendPath*inner_append,
2626
ParamPathInfo*param_info,
27-
List*runtime_clauses,
2827
doublesel)
2928
{
3029
returncreate_append_path_common(root,inner_append,
31-
param_info,runtime_clauses,
30+
param_info,
3231
&runtimeappend_path_methods,
3332
sizeof(RuntimeAppendPath),
3433
sel);

‎runtimeappend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern CustomScanMethodsruntimeappend_plan_methods;
5757
externCustomExecMethodsruntimeappend_exec_methods;
5858

5959
Path*create_runtimeappend_path(PlannerInfo*root,AppendPath*inner_append,
60-
ParamPathInfo*param_info,List*runtime_clauses,
60+
ParamPathInfo*param_info,
6161
doublesel);
6262

6363
Plan*create_runtimeappend_plan(PlannerInfo*root,RelOptInfo*rel,

‎sql/pg_pathman.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ INSERT INTO test.num_range_rel
4646
SELECTCOUNT(*)FROMtest.num_range_rel;
4747
SELECTCOUNT(*)FROM ONLYtest.num_range_rel;
4848

49+
SETpg_pathman.enable_runtimeappend= OFF;
50+
SETpg_pathman.enable_runtimemergeappend= OFF;
51+
4952
VACUUM;
5053

5154
/* update triggers test*/
@@ -115,8 +118,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM test.range_rel_1 UNION ALL SELECT * FROM test.
115118
SET enable_hashjoin= OFF;
116119
set enable_nestloop= OFF;
117120
SET enable_mergejoin=ON;
118-
SETpg_pathman.enable_runtimeappend= OFF;
119-
SETpg_pathman.enable_runtimemergeappend= OFF;
121+
120122
EXPLAIN (COSTS OFF)
121123
SELECT*FROMtest.range_rel j1
122124
JOINtest.range_rel j2onj2.id=j1.id
@@ -292,7 +294,7 @@ begin
292294
performtest.pathman_equal((plan->0->'Plan'->'Plans'->1->'Plans'->0->'Plans'->i->'Relation Name')::text,
293295
format('"runtime_test_2_%s"', i+1),
294296
'wrong partition');
295-
297+
296298
num= plan->0->'Plan'->'Plans'->1->'Plans'->0->'Plans'->i->'Actual Loops';
297299
performtest.pathman_assert(num=1,'expected no more than 1 loops');
298300
end loop;

‎utils.c

Lines changed: 0 additions & 64 deletions
This file was deleted.

‎utils.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp