1+ diff --git a/contrib/Makefile b/contrib/Makefile
2+ index abd780f277..601892ef54 100644
3+ --- a/contrib/Makefile
4+ +++ b/contrib/Makefile
5+ @@ -6,6 +6,7 @@ include $(top_builddir)/src/Makefile.global
6+
7+ SUBDIRS = \
8+ amcheck \
9+ + aqo \
10+ auth_delay \
11+ auto_explain \
12+ basic_archive \
113diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
2- index 18a5af6b91..18c2ed3bfd 100644
14+ index 8086607710..878a8ea9f9 100644
315--- a/src/backend/commands/explain.c
416+++ b/src/backend/commands/explain.c
517@@ -25,6 +25,7 @@
@@ -23,7 +35,7 @@ index 18a5af6b91..18c2ed3bfd 100644
2335
2436 /* Instrumentation data for SERIALIZE option */
2537 typedef struct SerializeMetrics
26- @@ -805 ,6 +812 ,10 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
38+ @@ -796 ,6 +803 ,10 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
2739 ExplainPropertyFloat("Execution Time", "ms", 1000.0 * totaltime, 3,
2840 es);
2941
@@ -34,7 +46,7 @@ index 18a5af6b91..18c2ed3bfd 100644
3446 ExplainCloseGroup("Query", NULL, true, es);
3547 }
3648
37- @@ -2001 ,6 +2012 ,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
49+ @@ -1886 ,6 +1897 ,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
3850 }
3951 }
4052
@@ -45,10 +57,10 @@ index 18a5af6b91..18c2ed3bfd 100644
4557 if (es->format == EXPLAIN_FORMAT_TEXT)
4658 appendStringInfoChar(es->str, '\n');
4759diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
48- index 2bb6db1df7..ac95740598 100644
60+ index 52ebdd90fc..da0e257120 100644
4961--- a/src/backend/optimizer/path/costsize.c
5062+++ b/src/backend/optimizer/path/costsize.c
51- @@ -109 ,6 +109 ,11 @@
63+ @@ -98 ,6 +98 ,11 @@
5264 #include "utils/spccache.h"
5365 #include "utils/tuplesort.h"
5466
@@ -60,15 +72,15 @@ index 2bb6db1df7..ac95740598 100644
6072
6173 #define LOG2(x) (log(x) / 0.693147180559945)
6274
63- @@ -202 ,7 +207 ,6 @@ static void set_rel_width(PlannerInfo *root, RelOptInfo *rel);
75+ @@ -191 ,7 +196 ,6 @@ static void set_rel_width(PlannerInfo *root, RelOptInfo *rel);
6476 static int32 get_expr_width(PlannerInfo *root, const Node *expr);
6577 static double relation_byte_size(double tuples, int width);
6678 static double page_size(double tuples, int width);
6779- static double get_parallel_divisor(Path *path);
6880
6981
7082 /*
71- @@ -5309 ,6 +5313 ,58 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
83+ @@ -5225 ,6 +5229 ,58 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
7284 }
7385
7486
@@ -127,7 +139,7 @@ index 2bb6db1df7..ac95740598 100644
127139 /*
128140 * set_baserel_size_estimates
129141 * Set the size estimates for the given base relation.
130- @@ -5325 ,19 +5381 ,10 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
142+ @@ -5241 ,19 +5297 ,10 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
131143 void
132144 set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
133145 {
@@ -148,7 +160,7 @@ index 2bb6db1df7..ac95740598 100644
148160
149161 cost_qual_eval(&rel->baserestrictcost, rel->baserestrictinfo, root);
150162
151- @@ -5348 ,13 +5395 ,33 @@ set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
163+ @@ -5264 ,13 +5311 ,33 @@ set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
152164 * get_parameterized_baserel_size
153165 * Make a size estimate for a parameterized scan of a base relation.
154166 *
@@ -184,7 +196,7 @@ index 2bb6db1df7..ac95740598 100644
184196 {
185197 List *allclauses;
186198 double nrows;
187- @@ -5383 ,6 +5450 ,36 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
199+ @@ -5299 ,6 +5366 ,36 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
188200 * set_joinrel_size_estimates
189201 * Set the size estimates for the given join relation.
190202 *
@@ -221,7 +233,7 @@ index 2bb6db1df7..ac95740598 100644
221233 * The rel's targetlist must have been constructed already, and a
222234 * restriction clause list that matches the given component rels must
223235 * be provided.
224- @@ -5402 ,11 +5499 ,11 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
236+ @@ -5318 ,11 +5415 ,11 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
225237 * build_joinrel_tlist, and baserestrictcost is not used for join rels.
226238 */
227239 void
@@ -238,7 +250,7 @@ index 2bb6db1df7..ac95740598 100644
238250 {
239251 rel->rows = calc_joinrel_size_estimate(root,
240252 rel,
241- @@ -5422 ,6 +5519 ,35 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
253+ @@ -5338 ,6 +5435 ,35 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
242254 * get_parameterized_joinrel_size
243255 * Make a size estimate for a parameterized scan of a join relation.
244256 *
@@ -274,7 +286,7 @@ index 2bb6db1df7..ac95740598 100644
274286 * 'rel' is the joinrel under consideration.
275287 * 'outer_path', 'inner_path' are (probably also parameterized) Paths that
276288 * produce the relations being joined.
277- @@ -5434 ,11 +5560 ,11 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
289+ @@ -5350 ,11 +5476 ,11 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
278290 * set_joinrel_size_estimates must have been applied already.
279291 */
280292 double
@@ -291,7 +303,7 @@ index 2bb6db1df7..ac95740598 100644
291303 {
292304 double nrows;
293305
294- @@ -6153 ,7 +6279 ,7 @@ set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
306+ @@ -6069 ,7 +6195 ,7 @@ set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
295307 /* Should only be applied to base relations */
296308 Assert(rel->relid > 0);
297309
@@ -300,7 +312,7 @@ index 2bb6db1df7..ac95740598 100644
300312
301313 cost_qual_eval(&rel->baserestrictcost, rel->baserestrictinfo, root);
302314
303- @@ -6446 ,7 +6572 ,7 @@ page_size(double tuples, int width)
315+ @@ -6362 ,7 +6488 ,7 @@ page_size(double tuples, int width)
304316 * Estimate the fraction of the work that each worker will do given the
305317 * number of workers budgeted for the path.
306318 */
@@ -310,7 +322,7 @@ index 2bb6db1df7..ac95740598 100644
310322 {
311323 double parallel_divisor = path->parallel_workers;
312324diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
313- index c13586c537..2f889570de 100644
325+ index c0af10ebd3..31e0ece45a 100644
314326--- a/src/backend/optimizer/plan/createplan.c
315327+++ b/src/backend/optimizer/plan/createplan.c
316328@@ -72,6 +72,7 @@
@@ -321,7 +333,7 @@ index c13586c537..2f889570de 100644
321333
322334 static Plan *create_plan_recurse(PlannerInfo *root, Path *best_path,
323335 int flags);
324- @@ -551 ,6 +552 ,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
336+ @@ -549 ,6 +550 ,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
325337 break;
326338 }
327339
@@ -332,7 +344,7 @@ index c13586c537..2f889570de 100644
332344 return plan;
333345 }
334346
335- @@ -5458 ,6 +5463 ,7 @@ copy_generic_path_info(Plan *dest, Path *src)
347+ @@ -5415 ,6 +5420 ,7 @@ copy_generic_path_info(Plan *dest, Path *src)
336348 dest->plan_width = src->pathtarget->width;
337349 dest->parallel_aware = src->parallel_aware;
338350 dest->parallel_safe = src->parallel_safe;
@@ -341,10 +353,10 @@ index c13586c537..2f889570de 100644
341353
342354 /*
343355diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
344- index 0f423e9684..8cd228baa1 100644
356+ index 0c7273b9cc..9399be1473 100644
345357--- a/src/backend/optimizer/plan/planner.c
346358+++ b/src/backend/optimizer/plan/planner.c
347- @@ -144 ,7 +144 ,8 @@ static List *extract_rollup_sets(List *groupingSets);
359+ @@ -142 ,7 +142 ,8 @@ static List *extract_rollup_sets(List *groupingSets);
348360 static List *reorder_grouping_sets(List *groupingSets, List *sortclause);
349361 static void standard_qp_callback(PlannerInfo *root, void *extra);
350362 static double get_number_of_groups(PlannerInfo *root,
@@ -354,7 +366,7 @@ index 0f423e9684..8cd228baa1 100644
354366 grouping_sets_data *gd,
355367 List *target_list);
356368 static RelOptInfo *create_grouping_paths(PlannerInfo *root,
357- @@ -3697 ,7 +3698 ,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
369+ @@ -3626 ,7 +3627 ,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
358370 */
359371 static double
360372 get_number_of_groups(PlannerInfo *root,
@@ -364,7 +376,7 @@ index 0f423e9684..8cd228baa1 100644
364376 grouping_sets_data *gd,
365377 List *target_list)
366378 {
367- @@ -3734 ,7 +3736 ,7 @@ get_number_of_groups(PlannerInfo *root,
379+ @@ -3663 ,7 +3665 ,7 @@ get_number_of_groups(PlannerInfo *root,
368380 GroupingSetData *gs = lfirst_node(GroupingSetData, lc3);
369381 double numGroups = estimate_num_groups(root,
370382 groupExprs,
@@ -373,7 +385,7 @@ index 0f423e9684..8cd228baa1 100644
373385 &gset,
374386 NULL);
375387
376- @@ -3760 ,7 +3762 ,7 @@ get_number_of_groups(PlannerInfo *root,
388+ @@ -3689 ,7 +3691 ,7 @@ get_number_of_groups(PlannerInfo *root,
377389 GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
378390 double numGroups = estimate_num_groups(root,
379391 groupExprs,
@@ -382,7 +394,7 @@ index 0f423e9684..8cd228baa1 100644
382394 &gset,
383395 NULL);
384396
385- @@ -3777 ,8 +3779 ,8 @@ get_number_of_groups(PlannerInfo *root,
397+ @@ -3706 ,8 +3708 ,8 @@ get_number_of_groups(PlannerInfo *root,
386398 groupExprs = get_sortgrouplist_exprs(root->processed_groupClause,
387399 target_list);
388400
@@ -393,7 +405,7 @@ index 0f423e9684..8cd228baa1 100644
393405 }
394406 }
395407 else if (parse->groupingSets)
396- @@ -4168 ,7 +4170 ,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
408+ @@ -4097 ,7 +4099 ,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
397409 * Estimate number of groups.
398410 */
399411 dNumGroups = get_number_of_groups(root,
@@ -403,7 +415,7 @@ index 0f423e9684..8cd228baa1 100644
403415 gd,
404416 extra->targetList);
405417
406- @@ -7405 ,13 +7408 ,15 @@ create_partial_grouping_paths(PlannerInfo *root,
418+ @@ -7303 ,13 +7306 ,15 @@ create_partial_grouping_paths(PlannerInfo *root,
407419 if (cheapest_total_path != NULL)
408420 dNumPartialGroups =
409421 get_number_of_groups(root,
@@ -422,7 +434,7 @@ index 0f423e9684..8cd228baa1 100644
422434 extra->targetList);
423435
424436diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
425- index d7266e4cdb..7e5b771d9f 100644
437+ index e05b21c884..5805136b70 100644
426438--- a/src/backend/optimizer/util/relnode.c
427439+++ b/src/backend/optimizer/util/relnode.c
428440@@ -286,6 +286,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
@@ -449,23 +461,23 @@ index d7266e4cdb..7e5b771d9f 100644
449461
450462 /* Compute information relevant to the foreign relations. */
451463 set_foreign_rel_properties(joinrel, outer_rel, inner_rel);
452- @@ -952 ,6 +953 ,7 @@ build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel,
464+ @@ -962 ,6 +963 ,7 @@ build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel,
453465 joinrel->all_partrels = NULL;
454466 joinrel->partexprs = NULL;
455467 joinrel->nullable_partexprs = NULL;
456468+ joinrel->ext_nodes = NULL;
457469
458470 /* Compute information relevant to foreign relations. */
459471 set_foreign_rel_properties(joinrel, outer_rel, inner_rel);
460- @@ -1530 ,6 +1532 ,7 @@ find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
472+ @@ -1542 ,6 +1544 ,7 @@ find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
461473 }
462474
463475
464476+ set_parampathinfo_postinit_hook_type parampathinfo_postinit_hook = NULL;
465477 /*
466478 * get_baserel_parampathinfo
467479 * Get the ParamPathInfo for a parameterized path for a base relation,
468- @@ -1622 ,6 +1625 ,10 @@ get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel,
480+ @@ -1634 ,6 +1637 ,10 @@ get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel,
469481 ppi->ppi_rows = rows;
470482 ppi->ppi_clauses = pclauses;
471483 ppi->ppi_serials = pserials;
@@ -476,7 +488,7 @@ index d7266e4cdb..7e5b771d9f 100644
476488 baserel->ppilist = lappend(baserel->ppilist, ppi);
477489
478490 return ppi;
479- @@ -1876 ,6 +1883 ,10 @@ get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
491+ @@ -1888 ,6 +1895 ,10 @@ get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
480492 ppi->ppi_rows = 0;
481493 ppi->ppi_clauses = NIL;
482494 ppi->ppi_serials = NULL;
@@ -488,7 +500,7 @@ index d7266e4cdb..7e5b771d9f 100644
488500
489501 return ppi;
490502diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
491- index 08fa6774d9..034b434773 100644
503+ index f4b3e91baa..45ccd76fd4 100644
492504--- a/src/backend/utils/adt/selfuncs.c
493505+++ b/src/backend/utils/adt/selfuncs.c
494506@@ -146,6 +146,7 @@
@@ -499,7 +511,7 @@ index 08fa6774d9..034b434773 100644
499511
500512 static double eqsel_internal(PG_FUNCTION_ARGS, bool negate);
501513 static double eqjoinsel_inner(Oid opfuncoid, Oid collation,
502- @@ -3345 ,6 +3346 ,20 @@ add_unique_group_var(PlannerInfo *root, List *varinfos,
514+ @@ -3344 ,6 +3345 ,20 @@ add_unique_group_var(PlannerInfo *root, List *varinfos,
503515 return varinfos;
504516 }
505517
@@ -521,10 +533,10 @@ index 08fa6774d9..034b434773 100644
521533 * estimate_num_groups - Estimate number of groups in a grouped query
522534 *
523535diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h
524- index 3ab0aae78f..5a257cdb0a 100644
536+ index 9b8b351d9a..f49233826a 100644
525537--- a/src/include/commands/explain.h
526538+++ b/src/include/commands/explain.h
527- @@ -87 ,6 +87 ,18 @@ extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
539+ @@ -85 ,6 +85 ,18 @@ extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
528540 typedef const char *(*explain_get_index_name_hook_type) (Oid indexId);
529541 extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook;
530542
@@ -544,10 +556,10 @@ index 3ab0aae78f..5a257cdb0a 100644
544556 extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
545557 ParamListInfo params, DestReceiver *dest);
546558diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
547- index 07e2415398..1413fbf03c 100644
559+ index 2ba297c117..36b66c43f6 100644
548560--- a/src/include/nodes/pathnodes.h
549561+++ b/src/include/nodes/pathnodes.h
550- @@ -1049 ,6 +1049 ,16 @@ typedef struct RelOptInfo
562+ @@ -1043 ,6 +1043 ,16 @@ typedef struct RelOptInfo
551563 List **partexprs pg_node_attr(read_write_ignore);
552564 /* Nullable partition key expressions */
553565 List **nullable_partexprs pg_node_attr(read_write_ignore);
@@ -564,7 +576,7 @@ index 07e2415398..1413fbf03c 100644
564576 } RelOptInfo;
565577
566578 /*
567- @@ -1586 ,6 +1596 ,10 @@ typedef struct ParamPathInfo
579+ @@ -1580 ,6 +1590 ,10 @@ typedef struct ParamPathInfo
568580 Cardinality ppi_rows; /* estimated number of result tuples */
569581 List *ppi_clauses; /* join clauses available from outer rels */
570582 Bitmapset *ppi_serials; /* set of rinfo_serial for enforced quals */
@@ -576,10 +588,10 @@ index 07e2415398..1413fbf03c 100644
576588
577589
578590diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
579- index 62cd6a6666..bb47a51ba7 100644
591+ index 1aeeaec95e..308f38214a 100644
580592--- a/src/include/nodes/plannodes.h
581593+++ b/src/include/nodes/plannodes.h
582- @@ -170 ,6 +170 ,9 @@ typedef struct Plan
594+ @@ -169 ,6 +169 ,9 @@ typedef struct Plan
583595 */
584596 Bitmapset *extParam;
585597 Bitmapset *allParam;
@@ -590,7 +602,7 @@ index 62cd6a6666..bb47a51ba7 100644
590602
591603 /* ----------------
592604diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
593- index 854a782944..9e8cde176f 100644
605+ index b1c51a4e70..1cb601e3b2 100644
594606--- a/src/include/optimizer/cost.h
595607+++ b/src/include/optimizer/cost.h
596608@@ -41,6 +41,37 @@ typedef enum
@@ -631,7 +643,7 @@ index 854a782944..9e8cde176f 100644
631643 /*
632644 * prototypes for costsize.c
633645 * routines to compute costs and sizes
634- @@ -192 ,10 +223 ,22 @@ extern void compute_semi_anti_join_factors(PlannerInfo *root,
646+ @@ -184 ,10 +215 ,22 @@ extern void compute_semi_anti_join_factors(PlannerInfo *root,
635647 SpecialJoinInfo *sjinfo,
636648 List *restrictlist,
637649 SemiAntiJoinFactors *semifactors);
@@ -654,7 +666,7 @@ index 854a782944..9e8cde176f 100644
654666 extern double get_parameterized_joinrel_size(PlannerInfo *root,
655667 RelOptInfo *rel,
656668 Path *outer_path,
657- @@ -207 ,6 +250 ,11 @@ extern void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
669+ @@ -199 ,6 +242 ,11 @@ extern void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
658670 RelOptInfo *inner_rel,
659671 SpecialJoinInfo *sjinfo,
660672 List *restrictlist);
@@ -666,15 +678,15 @@ index 854a782944..9e8cde176f 100644
666678 extern void set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel);
667679 extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
668680 extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
669- @@ -221,5 +269,6 @@ extern double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel,
681+ @@ -212,5 +260,6 @@ extern PathTarget *set_pathtarget_cost_width(PlannerInfo *root, PathTarget *targ
682+ extern double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel,
670683 Path *bitmapqual, double loop_count,
671684 Cost *cost_p, double *tuples_p);
672- extern double compute_gather_rows(Path *path);
673685+ extern double get_parallel_divisor(Path *path);
674686
675687 #endif /* COST_H */
676688diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
677- index 1035e6560c..27e42b2679 100644
689+ index 112e7c23d4..8397995e18 100644
678690--- a/src/include/optimizer/pathnode.h
679691+++ b/src/include/optimizer/pathnode.h
680692@@ -18,6 +18,10 @@
@@ -689,7 +701,7 @@ index 1035e6560c..27e42b2679 100644
689701 * prototypes for pathnode.c
690702 */
691703diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
692- index 93137261e4..0621c27595 100644
704+ index aafc173792..d520d8d547 100644
693705--- a/src/include/optimizer/planmain.h
694706+++ b/src/include/optimizer/planmain.h
695707@@ -24,6 +24,12 @@ extern PGDLLIMPORT double cursor_tuple_fraction;
0 commit comments