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

Commit758257a

Browse files
author
Daniil Anisimov
committed
Fix testing with WRITE_READ_PARSE_PLAN_TREES.
Change RestrictInfo to AQOClause.Add AQOConstNode to use it instead of useless nodes.Serialize/deserialize all AQOPlanNode and AQOConstNode fields.
1 parent5d9c6aa commit758257a

File tree

6 files changed

+431
-142
lines changed

6 files changed

+431
-142
lines changed

‎aqo_pg14.patch‎

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/contrib/Makefile b/contrib/Makefile
2-
indexf27e458482..0c62191904 100644
2+
indexf27e458482e..0c621919045 100644
33
--- a/contrib/Makefile
44
+++ b/contrib/Makefile
55
@@ -7,6 +7,7 @@ include $(top_builddir)/src/Makefile.global
@@ -11,7 +11,7 @@ index f27e458482..0c62191904 100644
1111
auto_explain\
1212
bloom\
1313
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
14-
index70551522da..958529fbab 100644
14+
index70551522dac..958529fbab4 100644
1515
--- a/src/backend/commands/explain.c
1616
+++ b/src/backend/commands/explain.c
1717
@@ -24,6 +24,7 @@
@@ -57,7 +57,7 @@ index 70551522da..958529fbab 100644
5757
if (es->format == EXPLAIN_FORMAT_TEXT)
5858
appendStringInfoChar(es->str, '\n');
5959
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
60-
index4d9746d54a..6fa85d1c71 100644
60+
index4d9746d54a0..6fa85d1c71f 100644
6161
--- a/src/backend/nodes/copyfuncs.c
6262
+++ b/src/backend/nodes/copyfuncs.c
6363
@@ -132,6 +132,7 @@ CopyPlanFields(const Plan *from, Plan *newnode)
@@ -69,35 +69,31 @@ index 4d9746d54a..6fa85d1c71 100644
6969

7070
/*
7171
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
72-
index58c2590698..1e06738a13 100644
72+
index58c2590698c..b9f39d36e03 100644
7373
--- a/src/backend/nodes/outfuncs.c
7474
+++ b/src/backend/nodes/outfuncs.c
7575
@@ -342,6 +342,7 @@ _outPlanInfo(StringInfo str, const Plan *node)
7676
WRITE_NODE_FIELD(initPlan);
7777
WRITE_BITMAPSET_FIELD(extParam);
7878
WRITE_BITMAPSET_FIELD(allParam);
79-
+/*WRITE_NODE_FIELD(ext_nodes); */
79+
+WRITE_NODE_FIELD(ext_nodes);
8080
}
8181

8282
/*
8383
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
84-
indexeaa51c5c06..6ad8b78c7d 100644
84+
indexeaa51c5c062..65741a86a05 100644
8585
--- a/src/backend/nodes/readfuncs.c
8686
+++ b/src/backend/nodes/readfuncs.c
87-
@@ -1628,6 +1628,11 @@ ReadCommonPlan(Plan *local_node)
87+
@@ -1628,6 +1628,7 @@ ReadCommonPlan(Plan *local_node)
8888
READ_NODE_FIELD(initPlan);
8989
READ_BITMAPSET_FIELD(extParam);
9090
READ_BITMAPSET_FIELD(allParam);
91-
+local_node->ext_nodes = NIL;
92-
+/* READ_NODE_FIELD(ext_nodes);
93-
+ * Don't serialize this field. It is required to serialize RestrictInfo and
94-
+ * EqualenceClass.
95-
+*/
91+
+READ_NODE_FIELD(ext_nodes);
9692
}
9793

9894
/*
9995
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
100-
index006f91f0a8..ef9c8ec581 100644
96+
index006f91f0a87..ef9c8ec5817 100644
10197
--- a/src/backend/optimizer/path/costsize.c
10298
+++ b/src/backend/optimizer/path/costsize.c
10399
@@ -98,6 +98,11 @@
@@ -362,7 +358,7 @@ index 006f91f0a8..ef9c8ec581 100644
362358
{
363359
doubleparallel_divisor = path->parallel_workers;
364360
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
365-
index0ed858f305..9d4a6c5903 100644
361+
index0ed858f305a..9d4a6c59030 100644
366362
--- a/src/backend/optimizer/plan/createplan.c
367363
+++ b/src/backend/optimizer/plan/createplan.c
368364
@@ -71,6 +71,7 @@
@@ -393,7 +389,7 @@ index 0ed858f305..9d4a6c5903 100644
393389

394390
/*
395391
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
396-
index70899e5430..34075cc87b 100644
392+
index5da863d85de..5b21ffd0667 100644
397393
--- a/src/backend/optimizer/plan/planner.c
398394
+++ b/src/backend/optimizer/plan/planner.c
399395
@@ -143,7 +143,8 @@ static List *extract_rollup_sets(List *groupingSets);
@@ -406,7 +402,7 @@ index 70899e5430..34075cc87b 100644
406402
grouping_sets_data *gd,
407403
List *target_list);
408404
static RelOptInfo *create_grouping_paths(PlannerInfo *root,
409-
@@ -3151,7 +3152,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
405+
@@ -3145,7 +3146,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
410406
*/
411407
static double
412408
get_number_of_groups(PlannerInfo *root,
@@ -416,7 +412,7 @@ index 70899e5430..34075cc87b 100644
416412
grouping_sets_data *gd,
417413
List *target_list)
418414
{
419-
@@ -3188,7 +3190,7 @@ get_number_of_groups(PlannerInfo *root,
415+
@@ -3182,7 +3184,7 @@ get_number_of_groups(PlannerInfo *root,
420416
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
421417
doublenumGroups = estimate_num_groups(root,
422418
groupExprs,
@@ -425,7 +421,7 @@ index 70899e5430..34075cc87b 100644
425421
&gset,
426422
NULL);
427423

428-
@@ -3214,7 +3216,7 @@ get_number_of_groups(PlannerInfo *root,
424+
@@ -3208,7 +3210,7 @@ get_number_of_groups(PlannerInfo *root,
429425
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
430426
doublenumGroups = estimate_num_groups(root,
431427
groupExprs,
@@ -434,7 +430,7 @@ index 70899e5430..34075cc87b 100644
434430
&gset,
435431
NULL);
436432

437-
@@ -3231,8 +3233,8 @@ get_number_of_groups(PlannerInfo *root,
433+
@@ -3225,8 +3227,8 @@ get_number_of_groups(PlannerInfo *root,
438434
groupExprs = get_sortgrouplist_exprs(parse->groupClause,
439435
target_list);
440436

@@ -445,7 +441,7 @@ index 70899e5430..34075cc87b 100644
445441
}
446442
}
447443
else if (parse->groupingSets)
448-
@@ -3619,7 +3621,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
444+
@@ -3613,7 +3615,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
449445
* Estimate number of groups.
450446
*/
451447
dNumGroups = get_number_of_groups(root,
@@ -455,7 +451,7 @@ index 70899e5430..34075cc87b 100644
455451
gd,
456452
extra->targetList);
457453

458-
@@ -6425,13 +6428,15 @@ create_partial_grouping_paths(PlannerInfo *root,
454+
@@ -6419,13 +6422,15 @@ create_partial_grouping_paths(PlannerInfo *root,
459455
if (cheapest_total_path != NULL)
460456
dNumPartialGroups =
461457
get_number_of_groups(root,
@@ -474,7 +470,7 @@ index 70899e5430..34075cc87b 100644
474470
extra->targetList);
475471

476472
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
477-
indexe105a4d5f1..c5bcc9d1d1 100644
473+
indexe105a4d5f1d..c5bcc9d1d15 100644
478474
--- a/src/backend/optimizer/util/relnode.c
479475
+++ b/src/backend/optimizer/util/relnode.c
480476
@@ -258,6 +258,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
@@ -540,7 +536,7 @@ index e105a4d5f1..c5bcc9d1d1 100644
540536

541537
return ppi;
542538
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
543-
index87879c9ddc..1aad8c43d9 100644
539+
index87879c9ddc8..1aad8c43d92 100644
544540
--- a/src/backend/utils/adt/selfuncs.c
545541
+++ b/src/backend/utils/adt/selfuncs.c
546542
@@ -143,6 +143,7 @@
@@ -573,7 +569,7 @@ index 87879c9ddc..1aad8c43d9 100644
573569
* estimate_num_groups- Estimate number of groups in a grouped query
574570
*
575571
diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h
576-
indexe94d9e49cf..49236ced77 100644
572+
indexe94d9e49cf6..49236ced77c 100644
577573
--- a/src/include/commands/explain.h
578574
+++ b/src/include/commands/explain.h
579575
@@ -75,6 +75,18 @@ extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
@@ -596,7 +592,7 @@ index e94d9e49cf..49236ced77 100644
596592
extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
597593
ParamListInfo params, DestReceiver *dest);
598594
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
599-
indexe370a01141..9f2f1628f5 100644
595+
index3c034fa3c5e..e441674970c 100644
600596
--- a/src/include/nodes/pathnodes.h
601597
+++ b/src/include/nodes/pathnodes.h
602598
@@ -756,6 +756,10 @@ typedef struct RelOptInfo
@@ -635,7 +631,7 @@ index e370a01141..9f2f1628f5 100644
635631

636632

637633
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
638-
index2308c80dde..a933afa483 100644
634+
index1c9357f6a77..58c005c1a9b 100644
639635
--- a/src/include/nodes/plannodes.h
640636
+++ b/src/include/nodes/plannodes.h
641637
@@ -158,6 +158,9 @@ typedef struct Plan
@@ -649,7 +645,7 @@ index 2308c80dde..a933afa483 100644
649645

650646
/* ----------------
651647
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
652-
index2113bc82de..bcc2520cec 100644
648+
index2113bc82de0..bcc2520cec5 100644
653649
--- a/src/include/optimizer/cost.h
654650
+++ b/src/include/optimizer/cost.h
655651
@@ -39,6 +39,37 @@ typedef enum
@@ -733,7 +729,7 @@ index 2113bc82de..bcc2520cec 100644
733729

734730
#endif/* COST_H */
735731
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
736-
index2922c0cdc1..c59dce6989 100644
732+
index2922c0cdc14..c59dce6989e 100644
737733
--- a/src/include/optimizer/pathnode.h
738734
+++ b/src/include/optimizer/pathnode.h
739735
@@ -18,6 +18,10 @@
@@ -748,7 +744,7 @@ index 2922c0cdc1..c59dce6989 100644
748744
* prototypes for pathnode.c
749745
*/
750746
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
751-
indexbf1adfc52a..9c78e0f4e0 100644
747+
indexbf1adfc52ac..9c78e0f4e02 100644
752748
--- a/src/include/optimizer/planmain.h
753749
+++ b/src/include/optimizer/planmain.h
754750
@@ -24,6 +24,12 @@ extern double cursor_tuple_fraction;
@@ -765,7 +761,7 @@ index bf1adfc52a..9c78e0f4e0 100644
765761
* prototypes for plan/planmain.c
766762
*/
767763
diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h
768-
index9dd444e1ff..cfaae98aa2 100644
764+
index9dd444e1ff5..b0b5a656185 100644
769765
--- a/src/include/utils/selfuncs.h
770766
+++ b/src/include/utils/selfuncs.h
771767
@@ -144,6 +144,13 @@ typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
@@ -782,13 +778,13 @@ index 9dd444e1ff..cfaae98aa2 100644
782778

783779
/* Functions in selfuncs.c */
784780

785-
@@ -213,6 +220,9 @@ extern void mergejoinscansel(PlannerInfo *root, Node *clause,
786-
extern double estimate_num_groups(PlannerInfo *root, List *groupExprs,
787-
double input_rows, List **pgset,
788-
EstimationInfo *estinfo);
781+
@@ -210,6 +217,9 @@ extern void mergejoinscansel(PlannerInfo *root, Node *clause,
782+
Selectivity *leftstart, Selectivity *leftend,
783+
Selectivity *rightstart, Selectivity *rightend);
784+
789785
+extern double estimate_num_groups_ext(PlannerInfo *root, List *groupExprs,
790786
+ Path *subpath, RelOptInfo *grouped_rel,
791787
+ List **pgset, EstimationInfo *estinfo);
792-
793-
extern void estimate_hash_bucket_stats(PlannerInfo *root,
794-
Node *hashkey, double nbuckets,
788+
extern double estimate_num_groups(PlannerInfo *root, List *groupExprs,
789+
double input_rows, List **pgset,
790+
EstimationInfo *estinfo);

‎cardinality_hooks.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ aqo_get_parameterized_baserel_size(PlannerInfo *root,
187187

188188
forboth(l,allclauses,l2,selectivities)
189189
{
190-
current_hash=get_clause_hash(
191-
((RestrictInfo*)lfirst(l))->clause,
190+
current_hash=get_clause_hash(((AQOClause*)lfirst(l))->clause,
192191
nargs,args_hash,eclass_hash);
193192
cache_selectivity(current_hash,rel->relid,rte->relid,
194193
*((double*)lfirst(l2)));

‎hash.c‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include"aqo.h"
2929
#include"hash.h"
30+
#include"path_utils.h"
3031

3132
staticintget_str_hash(constchar*str);
3233
staticintget_node_hash(Node*node);
@@ -218,11 +219,11 @@ get_fss_for_object(List *relsigns, List *clauselist,
218219
i=0;
219220
foreach(lc,clauselist)
220221
{
221-
RestrictInfo*rinfo=lfirst_node(RestrictInfo,lc);
222+
AQOClause*clause=(AQOClause*)lfirst(lc);
222223

223-
clause_hashes[i]=get_clause_hash(rinfo->clause,
224+
clause_hashes[i]=get_clause_hash(clause->clause,
224225
nargs,args_hash,eclass_hash);
225-
args=get_clause_args_ptr(rinfo->clause);
226+
args=get_clause_args_ptr(clause->clause);
226227
clause_has_consts[i]= (args!=NULL&&has_consts(*args));
227228
i++;
228229
}
@@ -317,14 +318,14 @@ get_clause_hash(Expr *clause, int nargs, int *args_hash, int *eclass_hash)
317318

318319
cclause=copyObject(clause);
319320
args=get_clause_args_ptr(cclause);
321+
/* XXX: Why does it work even if this loop is removed? */
320322
foreach(l,*args)
321323
{
322324
arg_eclass=get_arg_eclass(get_node_hash(lfirst(l)),
323325
nargs,args_hash,eclass_hash);
324326
if (arg_eclass!=0)
325327
{
326-
lfirst(l)=makeNode(Param);
327-
((Param*)lfirst(l))->paramid=arg_eclass;
328+
lfirst(l)=create_aqo_const_node(AQO_NODE_EXPR,arg_eclass);
328329
}
329330
}
330331
if (!clause_is_eq_clause(clause)||has_consts(*args))
@@ -554,7 +555,7 @@ get_arg_eclass(int arg_hash, int nargs, int *args_hash, int *eclass_hash)
554555
staticvoid
555556
get_clauselist_args(List*clauselist,int*nargs,int**args_hash)
556557
{
557-
RestrictInfo*rinfo;
558+
AQOClause*clause;
558559
List**args;
559560
ListCell*l;
560561
ListCell*l2;
@@ -564,9 +565,9 @@ get_clauselist_args(List *clauselist, int *nargs, int **args_hash)
564565

565566
foreach(l,clauselist)
566567
{
567-
rinfo= (RestrictInfo*)lfirst(l);
568-
args=get_clause_args_ptr(rinfo->clause);
569-
if (args!=NULL&&clause_is_eq_clause(rinfo->clause))
568+
clause= (AQOClause*)lfirst(l);
569+
args=get_clause_args_ptr(clause->clause);
570+
if (args!=NULL&&clause_is_eq_clause(clause->clause))
570571
foreach(l2,*args)
571572
if (!IsA(lfirst(l2),Const))
572573
cnt++;
@@ -575,9 +576,9 @@ get_clauselist_args(List *clauselist, int *nargs, int **args_hash)
575576
*args_hash=palloc(cnt*sizeof(**args_hash));
576577
foreach(l,clauselist)
577578
{
578-
rinfo= (RestrictInfo*)lfirst(l);
579-
args=get_clause_args_ptr(rinfo->clause);
580-
if (args!=NULL&&clause_is_eq_clause(rinfo->clause))
579+
clause= (AQOClause*)lfirst(l);
580+
args=get_clause_args_ptr(clause->clause);
581+
if (args!=NULL&&clause_is_eq_clause(clause->clause))
581582
foreach(l2,*args)
582583
if (!IsA(lfirst(l2),Const))
583584
(*args_hash)[i++]=get_node_hash(lfirst(l2));
@@ -632,7 +633,7 @@ disjoint_set_merge_eclasses(int *p, int v1, int v2)
632633
staticint*
633634
perform_eclasses_join(List*clauselist,intnargs,int*args_hash)
634635
{
635-
RestrictInfo*rinfo;
636+
AQOClause*clause;
636637
int*p;
637638
ListCell*l,
638639
*l2;
@@ -646,9 +647,9 @@ perform_eclasses_join(List *clauselist, int nargs, int *args_hash)
646647

647648
foreach(l,clauselist)
648649
{
649-
rinfo= (RestrictInfo*)lfirst(l);
650-
args=get_clause_args_ptr(rinfo->clause);
651-
if (args!=NULL&&clause_is_eq_clause(rinfo->clause))
650+
clause= (AQOClause*)lfirst(l);
651+
args=get_clause_args_ptr(clause->clause);
652+
if (args!=NULL&&clause_is_eq_clause(clause->clause))
652653
{
653654
i3=-1;
654655
foreach(l2,*args)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp