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

Commit8eaba42

Browse files
committed
refactoring in subsystem 'pg_compat'
1 parent92f321e commit8eaba42

File tree

3 files changed

+101
-49
lines changed

3 files changed

+101
-49
lines changed

‎src/pg_compat.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*
66
* Copyright (c) 2016, Postgres Professional
77
*
8+
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
9+
* Portions Copyright (c) 1994, Regents of the University of California
10+
*
811
* ------------------------------------------------------------------------
912
*/
1013

@@ -22,6 +25,7 @@
2225
#include<math.h>
2326

2427

28+
/* Common code */
2529
void
2630
set_append_rel_size_compat(PlannerInfo*root,RelOptInfo*rel,Indexrti)
2731
{
@@ -51,6 +55,7 @@ set_append_rel_size_compat(PlannerInfo *root, RelOptInfo *rel, Index rti)
5155
Assert(childrel->rows>0);
5256

5357
parent_rows+=childrel->rows;
58+
5459
#ifPG_VERSION_NUM >=90600
5560
parent_size+=childrel->reltarget->width*childrel->rows;
5661
#else
@@ -66,27 +71,20 @@ set_append_rel_size_compat(PlannerInfo *root, RelOptInfo *rel, Index rti)
6671
#else
6772
rel->width=rint(parent_size /parent_rows);
6873
#endif
74+
6975
rel->tuples=parent_rows;
7076
}
7177

72-
void
73-
adjust_targetlist_compat(PlannerInfo*root,RelOptInfo*dest,
74-
RelOptInfo*rel,AppendRelInfo*appinfo)
75-
{
76-
#ifPG_VERSION_NUM >=90600
77-
dest->reltarget->exprs= (List*)
78-
adjust_appendrel_attrs(root,
79-
(Node*)rel->reltarget->exprs,
80-
appinfo);
81-
#else
82-
dest->reltargetlist= (List*)
83-
adjust_appendrel_attrs(root,
84-
(Node*)rel->reltargetlist,
85-
appinfo);
86-
#endif
87-
}
78+
79+
/*
80+
* ----------
81+
* Variants
82+
* ----------
83+
*/
8884

8985
#ifPG_VERSION_NUM >=90600
86+
87+
9088
/*
9189
* make_result
9290
* Build a Result plan node
@@ -108,6 +106,7 @@ make_result(List *tlist,
108106
returnnode;
109107
}
110108

109+
111110
/*
112111
* If this relation could possibly be scanned from within a worker, then set
113112
* its consider_parallel flag.
@@ -256,6 +255,7 @@ set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel,
256255
rel->consider_parallel= true;
257256
}
258257

258+
259259
/*
260260
* create_plain_partial_paths
261261
* Build partial access paths for parallel scan of a plain relation
@@ -320,6 +320,7 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
320320

321321
#else/* PG_VERSION_NUM >= 90500 */
322322

323+
323324
/*
324325
* set_dummy_rel_pathlist
325326
* Build a dummy path for a relation that's been excluded by constraints

‎src/pg_compat.h

Lines changed: 83 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,76 +21,127 @@
2121

2222

2323
voidset_append_rel_size_compat(PlannerInfo*root,RelOptInfo*rel,Indexrti);
24-
voidadjust_targetlist_compat(PlannerInfo*root,RelOptInfo*dest,
25-
RelOptInfo*rel,AppendRelInfo*appinfo);
2624

2725

2826
#ifPG_VERSION_NUM >=90600
2927

3028

31-
#defineget_parameterized_joinrel_size_compat(root,rel,outer_path, \
32-
inner_path,sjinfo, \
33-
restrict_clauses) \
34-
get_parameterized_joinrel_size(root, rel, outer_path, \
35-
inner_path, sjinfo, \
36-
restrict_clauses)
29+
/* adjust_appendrel_attrs() */
30+
#defineadjust_rel_targetlist_compat(root,dst_rel,src_rel,appinfo) \
31+
do { \
32+
(dst_rel)->reltarget->exprs = (List *) \
33+
adjust_appendrel_attrs((root), \
34+
(Node *) (src_rel)->reltarget->exprs, \
35+
(appinfo)); \
36+
} while (0)
3737

38-
#definecheck_index_predicates_compat(rool,rel) \
39-
check_index_predicates(root, rel)
4038

39+
/* create_append_path() */
4140
#ifndefPGPRO_VERSION
4241
#definecreate_append_path_compat(rel,subpaths,required_outer,parallel_workers) \
43-
create_append_path(rel,subpaths,required_outer,parallel_workers)
42+
create_append_path((rel), (subpaths), (required_outer), (parallel_workers))
4443
#else
4544
#definecreate_append_path_compat(rel,subpaths,required_outer,parallel_workers) \
46-
create_append_path(rel, subpaths, required_outer, false, NIL, parallel_workers)
45+
create_append_path((rel), (subpaths), (required_outer), \
46+
false, NIL, (parallel_workers))
4747
#endif
4848

49-
#definepull_var_clause_compat(node,aggbehavior,phbehavior) \
50-
pull_var_clause(node, aggbehavior | phbehavior)
5149

52-
externvoidset_rel_consider_parallel(PlannerInfo*root,RelOptInfo*rel,
53-
RangeTblEntry*rte);
54-
#defineset_rel_consider_parallel_compat(root,rel,rte) \
55-
set_rel_consider_parallel(root, rel, rte)
50+
/* check_index_predicates() */
51+
#definecheck_index_predicates_compat(rool,rel) \
52+
check_index_predicates((root), (rel))
5653

57-
externvoidcreate_plain_partial_paths(PlannerInfo*root,RelOptInfo*rel);
54+
55+
/* create_plain_partial_paths() */
56+
externvoidcreate_plain_partial_paths(PlannerInfo*root,
57+
RelOptInfo*rel);
5858
#definecreate_plain_partial_paths_compat(root,rel) \
59-
create_plain_partial_paths(root, rel)
59+
create_plain_partial_paths((root), (rel))
60+
6061

61-
externResult*make_result(List*tlist,Node*resconstantqual,Plan*subplan);
62+
/* get_parameterized_joinrel_size() */
63+
#defineget_parameterized_joinrel_size_compat(root,rel,outer_path, \
64+
inner_path,sjinfo, \
65+
restrict_clauses) \
66+
get_parameterized_joinrel_size((root), (rel), (outer_path), \
67+
(inner_path), (sjinfo), \
68+
(restrict_clauses))
69+
70+
71+
/* make_result() */
72+
externResult*make_result(List*tlist,
73+
Node*resconstantqual,
74+
Plan*subplan);
6275
#definemake_result_compat(root,tlist,resconstantqual,subplan) \
63-
make_result(tlist, resconstantqual, subplan)
76+
make_result((tlist), (resconstantqual), (subplan))
77+
78+
79+
/* pull_var_clause() */
80+
#definepull_var_clause_compat(node,aggbehavior,phbehavior) \
81+
pull_var_clause((node), (aggbehavior) | (phbehavior))
82+
83+
84+
/* set_rel_consider_parallel() */
85+
externvoidset_rel_consider_parallel(PlannerInfo*root,
86+
RelOptInfo*rel,
87+
RangeTblEntry*rte);
88+
#defineset_rel_consider_parallel_compat(root,rel,rte) \
89+
set_rel_consider_parallel((root), (rel), (rte))
6490

6591

6692
#else/* PG_VERSION_NUM >= 90500 */
6793

6894

95+
/* adjust_appendrel_attrs() */
96+
#defineadjust_rel_targetlist_compat(root,dst_rel,src_rel,appinfo) \
97+
do { \
98+
(dst_rel)->reltargetlist = (List *) \
99+
adjust_appendrel_attrs((root), \
100+
(Node *) (src_rel)->reltargetlist, \
101+
(appinfo)); \
102+
} while (0)
103+
104+
105+
/* create_append_path() */
106+
#definecreate_append_path_compat(rel,subpaths,required_outer,parallel_workers) \
107+
create_append_path((rel), (subpaths), (required_outer))
108+
109+
110+
/* check_partial_indexes() */
111+
#definecheck_index_predicates_compat(rool,rel) \
112+
check_partial_indexes((root), (rel))
113+
114+
115+
/* create_plain_partial_paths() */
116+
#definecreate_plain_partial_paths_compat(root,rel) ((void) true)
117+
118+
119+
/* get_parameterized_joinrel_size() */
69120
#defineget_parameterized_joinrel_size_compat(root,rel, \
70121
outer_path, \
71122
inner_path, \
72123
sjinfo,restrict_clauses) \
73-
get_parameterized_joinrel_size(root,rel, \
124+
get_parameterized_joinrel_size((root), (rel), \
74125
(outer_path)->rows, \
75126
(inner_path)->rows, \
76-
sjinfo,restrict_clauses)
127+
(sjinfo), (restrict_clauses))
77128

78-
#definecheck_index_predicates_compat(rool,rel) \
79-
check_partial_indexes(root, rel)
80129

81-
#definecreate_append_path_compat(rel,subpaths,required_outer,parallel_workers) \
82-
create_append_path(rel, subpaths, required_outer)
130+
/* make_result() */
131+
#definemake_result_compat(root,tlist,resconstantqual,subplan) \
132+
make_result((root), (tlist), (resconstantqual), (subplan))
133+
83134

135+
/* pull_var_clause() */
84136
#definepull_var_clause_compat(node,aggbehavior,phbehavior) \
85-
pull_var_clause(node,aggbehavior,phbehavior)
137+
pull_var_clause((node), (aggbehavior), (phbehavior))
86138

87-
#definemake_result_compat(root,tlist,resconstantqual,subplan) \
88-
make_result(root, tlist, resconstantqual, subplan)
89139

140+
/* set_rel_consider_parallel() */
90141
#defineset_rel_consider_parallel_compat(root,rel,rte) ((void) true)
91142

92-
#definecreate_plain_partial_paths_compat(root,rel) ((void) true)
93143

144+
/* set_dummy_rel_pathlist() */
94145
voidset_dummy_rel_pathlist(RelOptInfo*rel);
95146

96147

‎src/pg_pathman.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ append_child_relation(PlannerInfo *root, Relation parent_relation,
341341
root->append_rel_list=lappend(root->append_rel_list,appinfo);
342342

343343
/* Adjust target list for this child */
344-
adjust_targetlist_compat(root,child_rel,parent_rel,appinfo);
344+
adjust_rel_targetlist_compat(root,child_rel,parent_rel,appinfo);
345345

346346
/*
347347
* Copy restrictions. If it's not the parent table, copy only

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp