Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 10a056f

Browse files
author
Alena Rybakina
committedMay 23, 2024
Update aqo_master.patch and test results
1 parent b454f65 commit 10a056f

File tree

6 files changed

+86
-85
lines changed

6 files changed

+86
-85
lines changed
 

‎aqo_master.patch

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
diff --git a/contrib/Makefile b/contrib/Makefile
2-
index bbf220407b..8225105893 100644
2+
index abd780f2774..601892ef54a 100644
33
--- a/contrib/Makefile
44
+++ b/contrib/Makefile
55
@@ -6,6 +6,7 @@ include $(top_builddir)/src/Makefile.global
66

77
SUBDIRS = \
8-
adminpack \
9-
+ aqo \
108
amcheck \
9+
+ aqo \
1110
auth_delay \
1211
auto_explain \
12+
basic_archive \
1313
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
14-
index 35c23bd27d..9dee2cee50 100644
14+
index 94511a5a024..81b04bf9eb9 100644
1515
--- a/src/backend/commands/explain.c
1616
+++ b/src/backend/commands/explain.c
1717
@@ -24,6 +24,7 @@
@@ -33,9 +33,9 @@ index 35c23bd27d..9dee2cee50 100644
3333
+ExplainOneNode_hook_type ExplainOneNode_hook = NULL;
3434
+
3535

36-
/* OR-able flags for ExplainXMLTag() */
37-
#define X_OPENING 0
38-
@@ -660,6 +667,10 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
36+
/* Instrumentation data for SERIALIZE option */
37+
typedef struct SerializeMetrics
38+
@@ -795,6 +802,10 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
3939
ExplainPropertyFloat("Execution Time", "ms", 1000.0 * totaltime, 3,
4040
es);
4141

@@ -46,7 +46,7 @@ index 35c23bd27d..9dee2cee50 100644
4646
ExplainCloseGroup("Query", NULL, true, es);
4747
}
4848

49-
@@ -1683,6 +1694,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
49+
@@ -1885,6 +1896,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
5050
}
5151
}
5252

@@ -57,10 +57,10 @@ index 35c23bd27d..9dee2cee50 100644
5757
if (es->format == EXPLAIN_FORMAT_TEXT)
5858
appendStringInfoChar(es->str, '\n');
5959
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
60-
index 7918bb6f0d..36099866bb 100644
60+
index ee23ed7835d..4ca51d39d1c 100644
6161
--- a/src/backend/optimizer/path/costsize.c
6262
+++ b/src/backend/optimizer/path/costsize.c
63-
@@ -99,6 +99,11 @@
63+
@@ -98,6 +98,11 @@
6464
#include "utils/spccache.h"
6565
#include "utils/tuplesort.h"
6666

@@ -72,15 +72,15 @@ index 7918bb6f0d..36099866bb 100644
7272

7373
#define LOG2(x) (log(x) / 0.693147180559945)
7474

75-
@@ -191,7 +196,6 @@ static Cost append_nonpartial_cost(List *subpaths, int numpaths,
76-
static void set_rel_width(PlannerInfo *root, RelOptInfo *rel);
75+
@@ -191,7 +196,6 @@ static void set_rel_width(PlannerInfo *root, RelOptInfo *rel);
76+
static int32 get_expr_width(PlannerInfo *root, const Node *expr);
7777
static double relation_byte_size(double tuples, int width);
7878
static double page_size(double tuples, int width);
7979
-static double get_parallel_divisor(Path *path);
8080

8181

8282
/*
83-
@@ -4976,6 +4980,58 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
83+
@@ -5222,6 +5226,58 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
8484
}
8585

8686

@@ -139,7 +139,7 @@ index 7918bb6f0d..36099866bb 100644
139139
/*
140140
* set_baserel_size_estimates
141141
* Set the size estimates for the given base relation.
142-
@@ -4992,19 +5048,10 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
142+
@@ -5238,19 +5294,10 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
143143
void
144144
set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
145145
{
@@ -160,7 +160,7 @@ index 7918bb6f0d..36099866bb 100644
160160

161161
cost_qual_eval(&rel->baserestrictcost, rel->baserestrictinfo, root);
162162

163-
@@ -5015,13 +5062,33 @@ set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
163+
@@ -5261,13 +5308,33 @@ set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
164164
* get_parameterized_baserel_size
165165
* Make a size estimate for a parameterized scan of a base relation.
166166
*
@@ -196,7 +196,7 @@ index 7918bb6f0d..36099866bb 100644
196196
{
197197
List *allclauses;
198198
double nrows;
199-
@@ -5050,6 +5117,36 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
199+
@@ -5296,6 +5363,36 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
200200
* set_joinrel_size_estimates
201201
* Set the size estimates for the given join relation.
202202
*
@@ -233,7 +233,7 @@ index 7918bb6f0d..36099866bb 100644
233233
* The rel's targetlist must have been constructed already, and a
234234
* restriction clause list that matches the given component rels must
235235
* be provided.
236-
@@ -5069,11 +5166,11 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
236+
@@ -5315,11 +5412,11 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
237237
* build_joinrel_tlist, and baserestrictcost is not used for join rels.
238238
*/
239239
void
@@ -250,7 +250,7 @@ index 7918bb6f0d..36099866bb 100644
250250
{
251251
rel->rows = calc_joinrel_size_estimate(root,
252252
rel,
253-
@@ -5089,6 +5186,35 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
253+
@@ -5335,6 +5432,35 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
254254
* get_parameterized_joinrel_size
255255
* Make a size estimate for a parameterized scan of a join relation.
256256
*
@@ -286,7 +286,7 @@ index 7918bb6f0d..36099866bb 100644
286286
* 'rel' is the joinrel under consideration.
287287
* 'outer_path', 'inner_path' are (probably also parameterized) Paths that
288288
* produce the relations being joined.
289-
@@ -5101,11 +5227,11 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
289+
@@ -5347,11 +5473,11 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
290290
* set_joinrel_size_estimates must have been applied already.
291291
*/
292292
double
@@ -303,7 +303,7 @@ index 7918bb6f0d..36099866bb 100644
303303
{
304304
double nrows;
305305

306-
@@ -5820,7 +5946,7 @@ set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
306+
@@ -6066,7 +6192,7 @@ set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
307307
/* Should only be applied to base relations */
308308
Assert(rel->relid > 0);
309309

@@ -312,7 +312,7 @@ index 7918bb6f0d..36099866bb 100644
312312

313313
cost_qual_eval(&rel->baserestrictcost, rel->baserestrictinfo, root);
314314

315-
@@ -6107,7 +6233,7 @@ page_size(double tuples, int width)
315+
@@ -6359,7 +6485,7 @@ page_size(double tuples, int width)
316316
* Estimate the fraction of the work that each worker will do given the
317317
* number of workers budgeted for the path.
318318
*/
@@ -322,18 +322,18 @@ index 7918bb6f0d..36099866bb 100644
322322
{
323323
double parallel_divisor = path->parallel_workers;
324324
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
325-
index 1b11852814..9629876f9f 100644
325+
index 6b64c4a362d..4e44babc0a2 100644
326326
--- a/src/backend/optimizer/plan/createplan.c
327327
+++ b/src/backend/optimizer/plan/createplan.c
328-
@@ -70,6 +70,7 @@
328+
@@ -71,6 +71,7 @@
329329
#define CP_LABEL_TLIST 0x0004 /* tlist must contain sortgrouprefs */
330330
#define CP_IGNORE_TLIST 0x0008 /* caller will replace tlist */
331331

332332
+create_plan_hook_type create_plan_hook = NULL;
333333

334334
static Plan *create_plan_recurse(PlannerInfo *root, Path *best_path,
335335
int flags);
336-
@@ -546,6 +547,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
336+
@@ -548,6 +549,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
337337
break;
338338
}
339339

@@ -344,7 +344,7 @@ index 1b11852814..9629876f9f 100644
344344
return plan;
345345
}
346346

347-
@@ -5379,6 +5384,7 @@ copy_generic_path_info(Plan *dest, Path *src)
347+
@@ -5414,6 +5419,7 @@ copy_generic_path_info(Plan *dest, Path *src)
348348
dest->plan_width = src->pathtarget->width;
349349
dest->parallel_aware = src->parallel_aware;
350350
dest->parallel_safe = src->parallel_safe;
@@ -353,10 +353,10 @@ index 1b11852814..9629876f9f 100644
353353

354354
/*
355355
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
356-
index db5ff6fdca..f2ace8d1be 100644
356+
index 032818423f6..a5c7e71b724 100644
357357
--- a/src/backend/optimizer/plan/planner.c
358358
+++ b/src/backend/optimizer/plan/planner.c
359-
@@ -145,7 +145,8 @@ static List *extract_rollup_sets(List *groupingSets);
359+
@@ -142,7 +142,8 @@ static List *extract_rollup_sets(List *groupingSets);
360360
static List *reorder_grouping_sets(List *groupingSets, List *sortclause);
361361
static void standard_qp_callback(PlannerInfo *root, void *extra);
362362
static double get_number_of_groups(PlannerInfo *root,
@@ -366,7 +366,7 @@ index db5ff6fdca..f2ace8d1be 100644
366366
grouping_sets_data *gd,
367367
List *target_list);
368368
static RelOptInfo *create_grouping_paths(PlannerInfo *root,
369-
@@ -3554,7 +3555,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
369+
@@ -3531,7 +3532,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
370370
*/
371371
static double
372372
get_number_of_groups(PlannerInfo *root,
@@ -376,7 +376,7 @@ index db5ff6fdca..f2ace8d1be 100644
376376
grouping_sets_data *gd,
377377
List *target_list)
378378
{
379-
@@ -3591,7 +3593,7 @@ get_number_of_groups(PlannerInfo *root,
379+
@@ -3568,7 +3570,7 @@ get_number_of_groups(PlannerInfo *root,
380380
GroupingSetData *gs = lfirst_node(GroupingSetData, lc3);
381381
double numGroups = estimate_num_groups(root,
382382
groupExprs,
@@ -385,7 +385,7 @@ index db5ff6fdca..f2ace8d1be 100644
385385
&gset,
386386
NULL);
387387

388-
@@ -3617,7 +3619,7 @@ get_number_of_groups(PlannerInfo *root,
388+
@@ -3594,7 +3596,7 @@ get_number_of_groups(PlannerInfo *root,
389389
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
390390
double numGroups = estimate_num_groups(root,
391391
groupExprs,
@@ -394,7 +394,7 @@ index db5ff6fdca..f2ace8d1be 100644
394394
&gset,
395395
NULL);
396396

397-
@@ -3634,8 +3636,8 @@ get_number_of_groups(PlannerInfo *root,
397+
@@ -3611,8 +3613,8 @@ get_number_of_groups(PlannerInfo *root,
398398
groupExprs = get_sortgrouplist_exprs(root->processed_groupClause,
399399
target_list);
400400

@@ -405,7 +405,7 @@ index db5ff6fdca..f2ace8d1be 100644
405405
}
406406
}
407407
else if (parse->groupingSets)
408-
@@ -4025,7 +4027,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
408+
@@ -4002,7 +4004,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
409409
* Estimate number of groups.
410410
*/
411411
dNumGroups = get_number_of_groups(root,
@@ -415,7 +415,7 @@ index db5ff6fdca..f2ace8d1be 100644
415415
gd,
416416
extra->targetList);
417417

418-
@@ -7127,13 +7130,15 @@ create_partial_grouping_paths(PlannerInfo *root,
418+
@@ -7207,13 +7210,15 @@ create_partial_grouping_paths(PlannerInfo *root,
419419
if (cheapest_total_path != NULL)
420420
dNumPartialGroups =
421421
get_number_of_groups(root,
@@ -434,50 +434,50 @@ index db5ff6fdca..f2ace8d1be 100644
434434
extra->targetList);
435435

436436
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
437-
index ad84cc43e1..8e1e436caf 100644
437+
index e05b21c884e..5805136b70f 100644
438438
--- a/src/backend/optimizer/util/relnode.c
439439
+++ b/src/backend/optimizer/util/relnode.c
440-
@@ -272,6 +272,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
440+
@@ -286,6 +286,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
441441
rel->all_partrels = NULL;
442442
rel->partexprs = NULL;
443443
rel->nullable_partexprs = NULL;
444444
+ rel->ext_nodes = NULL;
445445

446446
/*
447447
* Pass assorted information down the inheritance hierarchy.
448-
@@ -402,7 +403,6 @@ find_base_rel(PlannerInfo *root, int relid)
448+
@@ -422,7 +423,6 @@ find_base_rel(PlannerInfo *root, int relid)
449449
if (rel)
450450
return rel;
451451
}
452452
-
453453
elog(ERROR, "no relation entry for relid %d", relid);
454454

455455
return NULL; /* keep compiler quiet */
456-
@@ -732,6 +732,7 @@ build_join_rel(PlannerInfo *root,
456+
@@ -768,6 +768,7 @@ build_join_rel(PlannerInfo *root,
457457
joinrel->all_partrels = NULL;
458458
joinrel->partexprs = NULL;
459459
joinrel->nullable_partexprs = NULL;
460460
+ joinrel->ext_nodes = NULL;
461461

462462
/* Compute information relevant to the foreign relations. */
463463
set_foreign_rel_properties(joinrel, outer_rel, inner_rel);
464-
@@ -917,6 +918,7 @@ build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel,
464+
@@ -962,6 +963,7 @@ build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel,
465465
joinrel->all_partrels = NULL;
466466
joinrel->partexprs = NULL;
467467
joinrel->nullable_partexprs = NULL;
468468
+ joinrel->ext_nodes = NULL;
469469

470470
/* Compute information relevant to foreign relations. */
471471
set_foreign_rel_properties(joinrel, outer_rel, inner_rel);
472-
@@ -1467,6 +1469,7 @@ find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
472+
@@ -1542,6 +1544,7 @@ find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
473473
}
474474

475475

476476
+set_parampathinfo_postinit_hook_type parampathinfo_postinit_hook = NULL;
477477
/*
478478
* get_baserel_parampathinfo
479479
* Get the ParamPathInfo for a parameterized path for a base relation,
480-
@@ -1546,6 +1549,10 @@ get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel,
480+
@@ -1634,6 +1637,10 @@ get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel,
481481
ppi->ppi_rows = rows;
482482
ppi->ppi_clauses = pclauses;
483483
ppi->ppi_serials = pserials;
@@ -488,7 +488,7 @@ index ad84cc43e1..8e1e436caf 100644
488488
baserel->ppilist = lappend(baserel->ppilist, ppi);
489489

490490
return ppi;
491-
@@ -1799,6 +1806,10 @@ get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
491+
@@ -1888,6 +1895,10 @@ get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
492492
ppi->ppi_rows = 0;
493493
ppi->ppi_clauses = NIL;
494494
ppi->ppi_serials = NULL;
@@ -500,18 +500,18 @@ index ad84cc43e1..8e1e436caf 100644
500500

501501
return ppi;
502502
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
503-
index fe37e65af0..0e5299078b 100644
503+
index 5f5d7959d8e..20f63aae589 100644
504504
--- a/src/backend/utils/adt/selfuncs.c
505505
+++ b/src/backend/utils/adt/selfuncs.c
506-
@@ -145,6 +145,7 @@
506+
@@ -146,6 +146,7 @@
507507
/* Hooks for plugins to get control when we ask for stats */
508508
get_relation_stats_hook_type get_relation_stats_hook = NULL;
509509
get_index_stats_hook_type get_index_stats_hook = NULL;
510510
+estimate_num_groups_hook_type estimate_num_groups_hook = NULL;
511511

512512
static double eqsel_internal(PG_FUNCTION_ARGS, bool negate);
513513
static double eqjoinsel_inner(Oid opfuncoid, Oid collation,
514-
@@ -3311,6 +3312,20 @@ add_unique_group_var(PlannerInfo *root, List *varinfos,
514+
@@ -3341,6 +3342,20 @@ add_unique_group_var(PlannerInfo *root, List *varinfos,
515515
return varinfos;
516516
}
517517

@@ -533,10 +533,10 @@ index fe37e65af0..0e5299078b 100644
533533
* estimate_num_groups - Estimate number of groups in a grouped query
534534
*
535535
diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h
536-
index 7c1071ddd1..72e954dd3e 100644
536+
index 9b8b351d9a2..f49233826af 100644
537537
--- a/src/include/commands/explain.h
538538
+++ b/src/include/commands/explain.h
539-
@@ -75,6 +75,18 @@ extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
539+
@@ -85,6 +85,18 @@ extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
540540
typedef const char *(*explain_get_index_name_hook_type) (Oid indexId);
541541
extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook;
542542

@@ -556,10 +556,10 @@ index 7c1071ddd1..72e954dd3e 100644
556556
extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
557557
ParamListInfo params, DestReceiver *dest);
558558
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
559-
index 62d9460258..a946d05e60 100644
559+
index 14ef296ab72..b1316b8f791 100644
560560
--- a/src/include/nodes/pathnodes.h
561561
+++ b/src/include/nodes/pathnodes.h
562-
@@ -1038,6 +1038,16 @@ typedef struct RelOptInfo
562+
@@ -1039,6 +1039,16 @@ typedef struct RelOptInfo
563563
List **partexprs pg_node_attr(read_write_ignore);
564564
/* Nullable partition key expressions */
565565
List **nullable_partexprs pg_node_attr(read_write_ignore);
@@ -576,7 +576,7 @@ index 62d9460258..a946d05e60 100644
576576
} RelOptInfo;
577577

578578
/*
579-
@@ -1558,6 +1568,10 @@ typedef struct ParamPathInfo
579+
@@ -1569,6 +1579,10 @@ typedef struct ParamPathInfo
580580
Cardinality ppi_rows; /* estimated number of result tuples */
581581
List *ppi_clauses; /* join clauses available from outer rels */
582582
Bitmapset *ppi_serials; /* set of rinfo_serial for enforced quals */
@@ -588,10 +588,10 @@ index 62d9460258..a946d05e60 100644
588588

589589

590590
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
591-
index 4781a9c632..03f8216664 100644
591+
index 1aeeaec95e1..308f38214a3 100644
592592
--- a/src/include/nodes/plannodes.h
593593
+++ b/src/include/nodes/plannodes.h
594-
@@ -173,6 +173,9 @@ typedef struct Plan
594+
@@ -169,6 +169,9 @@ typedef struct Plan
595595
*/
596596
Bitmapset *extParam;
597597
Bitmapset *allParam;
@@ -602,7 +602,7 @@ index 4781a9c632..03f8216664 100644
602602

603603
/* ----------------
604604
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
605-
index 6cf49705d3..6a96baf130 100644
605+
index b1c51a4e70f..1cb601e3b27 100644
606606
--- a/src/include/optimizer/cost.h
607607
+++ b/src/include/optimizer/cost.h
608608
@@ -41,6 +41,37 @@ typedef enum
@@ -678,15 +678,15 @@ index 6cf49705d3..6a96baf130 100644
678678
extern void set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel);
679679
extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
680680
extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
681-
@@ -211,5 +259,6 @@ extern void set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel);
682-
extern PathTarget *set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target);
681+
@@ -212,5 +260,6 @@ extern PathTarget *set_pathtarget_cost_width(PlannerInfo *root, PathTarget *targ
683682
extern double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel,
684-
Path *bitmapqual, int loop_count, Cost *cost, double *tuple);
683+
Path *bitmapqual, double loop_count,
684+
Cost *cost_p, double *tuples_p);
685685
+extern double get_parallel_divisor(Path *path);
686686

687687
#endif /* COST_H */
688688
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
689-
index 69be701b16..497abb69c7 100644
689+
index 112e7c23d4e..8397995e183 100644
690690
--- a/src/include/optimizer/pathnode.h
691691
+++ b/src/include/optimizer/pathnode.h
692692
@@ -18,6 +18,10 @@
@@ -701,7 +701,7 @@ index 69be701b16..497abb69c7 100644
701701
* prototypes for pathnode.c
702702
*/
703703
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
704-
index 5fc900737d..5e5ce876c4 100644
704+
index aafc1737921..d520d8d5475 100644
705705
--- a/src/include/optimizer/planmain.h
706706
+++ b/src/include/optimizer/planmain.h
707707
@@ -24,6 +24,12 @@ extern PGDLLIMPORT double cursor_tuple_fraction;
@@ -718,10 +718,10 @@ index 5fc900737d..5e5ce876c4 100644
718718
* prototypes for plan/planmain.c
719719
*/
720720
diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h
721-
index 2f76c473db..98b9a95d0f 100644
721+
index f2563ad1cb3..0beac5f3139 100644
722722
--- a/src/include/utils/selfuncs.h
723723
+++ b/src/include/utils/selfuncs.h
724-
@@ -144,6 +144,13 @@ typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
724+
@@ -147,6 +147,13 @@ typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
725725
AttrNumber indexattnum,
726726
VariableStatData *vardata);
727727
extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;
@@ -735,7 +735,7 @@ index 2f76c473db..98b9a95d0f 100644
735735

736736
/* Functions in selfuncs.c */
737737

738-
@@ -210,6 +217,9 @@ extern void mergejoinscansel(PlannerInfo *root, Node *clause,
738+
@@ -213,6 +220,9 @@ extern void mergejoinscansel(PlannerInfo *root, Node *clause,
739739
Selectivity *leftstart, Selectivity *leftend,
740740
Selectivity *rightstart, Selectivity *rightend);
741741

‎expected/aqo_fdw.out

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,27 @@ WHERE str NOT LIKE '%Memory%';
258258

259259
DROP TABLE main, local_main_p0, local_main_p1;
260260
DROP TABLE ref, local_ref_p0, local_ref_p1;
261-
ALTER SERVER loopback OPTIONS (DROP fdw_tuple_cost);
261+
--ALTER SERVER loopback OPTIONS (DROP fdw_tuple_cost);
262262
reset enable_partitionwise_join;
263263
-- TODO: Non-mergejoinable join condition.
264264
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
265265
SELECT * FROM frgn AS a, frgn AS b WHERE a.x<b.x;
266-
QUERY PLAN
267-
-------------------------------------------
268-
Foreign Scan (actual rows=0 loops=1)
266+
QUERY PLAN
267+
------------------------------------------------------------
268+
Nested Loop (actual rows=0 loops=1)
269269
AQO not used
270-
Relations: (frgn a) INNER JOIN (frgn b)
270+
Join Filter: (a.x < b.x)
271+
Rows Removed by Join Filter: 1
272+
-> Foreign Scan on frgn a (actual rows=1 loops=1)
273+
AQO not used
274+
-> Materialize (actual rows=1 loops=1)
275+
AQO not used
276+
-> Foreign Scan on frgn b (actual rows=1 loops=1)
277+
AQO not used
271278
Using aqo: true
272279
AQO mode: LEARN
273280
JOINS: 0
274-
(6 rows)
281+
(13 rows)
275282

276283
SELECT str FROM expln('
277284
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, VERBOSE)

‎expected/top_queries.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ WHERE te.fshash = (
7979
);
8080
to_char
8181
-----------
82-
1.94e+00
82+
1.95e+00
8383
(1 row)
8484

8585
-- Should return zero

‎expected/unsupported.out

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
203203
----------------------------------------------------------
204204
Aggregate (actual rows=1 loops=1)
205205
AQO not used
206-
InitPlan 1 (returns $0)
206+
InitPlan 1
207207
-> Aggregate (actual rows=1 loops=1)
208208
AQO not used
209209
-> Seq Scan on t t_1 (actual rows=50 loops=1)
@@ -212,7 +212,7 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
212212
Rows Removed by Filter: 950
213213
-> Seq Scan on t (actual rows=50 loops=1)
214214
AQO: rows=50, error=0%
215-
Filter: ((x)::numeric = $0)
215+
Filter: ((x)::numeric = (InitPlan 1).col1)
216216
Rows Removed by Filter: 950
217217
Using aqo: true
218218
AQO mode: LEARN
@@ -253,13 +253,13 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
253253
SELECT count(*) FROM t WHERE
254254
x = (SELECT avg(x) FROM t t0 WHERE t0.x = t.x + 21) OR
255255
x IN (SELECT avg(x) FROM t t0 WHERE t0.x = t.x + 21);
256-
QUERY PLAN
257-
-------------------------------------------------------------------
256+
QUERY PLAN
257+
-------------------------------------------------------------------------------------------
258258
Aggregate (actual rows=1 loops=1)
259259
AQO not used
260260
-> Seq Scan on t (actual rows=0 loops=1)
261261
AQO not used
262-
Filter: (((x)::numeric = (SubPlan 1)) OR (SubPlan 2))
262+
Filter: (((x)::numeric = (SubPlan 1)) OR (ANY ((x)::numeric = (SubPlan 2).col1)))
263263
Rows Removed by Filter: 1000
264264
SubPlan 1
265265
-> Aggregate (actual rows=1 loops=1000)
@@ -284,13 +284,13 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
284284
SELECT count(*) FROM t WHERE
285285
x = (SELECT avg(x) FROM t t0 WHERE t0.x = t.x + 21) OR
286286
x IN (SELECT avg(x) FROM t t0 WHERE t0.x = t.x + 21);
287-
QUERY PLAN
288-
-------------------------------------------------------------------
287+
QUERY PLAN
288+
-------------------------------------------------------------------------------------------
289289
Aggregate (actual rows=1 loops=1)
290290
AQO not used
291291
-> Seq Scan on t (actual rows=0 loops=1)
292292
AQO: rows=1, error=100%
293-
Filter: (((x)::numeric = (SubPlan 1)) OR (SubPlan 2))
293+
Filter: (((x)::numeric = (SubPlan 1)) OR (ANY ((x)::numeric = (SubPlan 2).col1)))
294294
Rows Removed by Filter: 1000
295295
SubPlan 1
296296
-> Aggregate (actual rows=1 loops=1000)
@@ -316,13 +316,13 @@ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
316316
SELECT count(*) FROM t WHERE
317317
x = (SELECT avg(x) FROM t t0 WHERE t0.x = t.x + 22) OR
318318
x IN (SELECT avg(x) FROM t t0 WHERE t0.x = t.x + 23);
319-
QUERY PLAN
320-
-------------------------------------------------------------------
319+
QUERY PLAN
320+
-------------------------------------------------------------------------------------------
321321
Aggregate (actual rows=1 loops=1)
322322
AQO not used
323323
-> Seq Scan on t (actual rows=0 loops=1)
324324
AQO: rows=1, error=100%
325-
Filter: (((x)::numeric = (SubPlan 1)) OR (SubPlan 2))
325+
Filter: (((x)::numeric = (SubPlan 1)) OR (ANY ((x)::numeric = (SubPlan 2).col1)))
326326
Rows Removed by Filter: 1000
327327
SubPlan 1
328328
-> Aggregate (actual rows=1 loops=1000)

‎preprocessing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ aqo_planner(Query *parse,
156156

157157
/* Check unlucky case (get a hash of zero) */
158158
if (parse->queryId == UINT64CONST(0))
159-
JumbleQuery(parse, query_string);
159+
JumbleQuery(parse);
160160

161161
Assert(parse->utilityStmt == NULL);
162162
Assert(parse->queryId != UINT64CONST(0));

‎storage.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ aqo_query_stat(PG_FUNCTION_ARGS)
422422
}
423423

424424
LWLockRelease(&aqo_state->stat_lock);
425-
tuplestore_donestoring(tupstore);
426425
return (Datum) 0;
427426
}
428427

@@ -1185,7 +1184,6 @@ aqo_query_texts(PG_FUNCTION_ARGS)
11851184
}
11861185

11871186
LWLockRelease(&aqo_state->qtexts_lock);
1188-
tuplestore_donestoring(tupstore);
11891187
return (Datum) 0;
11901188
}
11911189

@@ -1820,7 +1818,6 @@ aqo_data(PG_FUNCTION_ARGS)
18201818
}
18211819

18221820
LWLockRelease(&aqo_state->data_lock);
1823-
tuplestore_donestoring(tupstore);
18241821
return (Datum) 0;
18251822
}
18261823

@@ -1942,7 +1939,6 @@ aqo_queries(PG_FUNCTION_ARGS)
19421939
}
19431940

19441941
LWLockRelease(&aqo_state->queries_lock);
1945-
tuplestore_donestoring(tupstore);
19461942
return (Datum) 0;
19471943
}
19481944

@@ -2538,7 +2534,6 @@ aqo_cardinality_error(PG_FUNCTION_ARGS)
25382534
LWLockRelease(&aqo_state->stat_lock);
25392535
LWLockRelease(&aqo_state->queries_lock);
25402536

2541-
tuplestore_donestoring(tupstore);
25422537
return (Datum) 0;
25432538
}
25442539

@@ -2642,7 +2637,6 @@ aqo_execution_time(PG_FUNCTION_ARGS)
26422637
LWLockRelease(&aqo_state->stat_lock);
26432638
LWLockRelease(&aqo_state->queries_lock);
26442639

2645-
tuplestore_donestoring(tupstore);
26462640
return (Datum) 0;
26472641
}
26482642

0 commit comments

Comments
 (0)
Please sign in to comment.