Skip to content

Commit 6ce6354

Browse files
author
Maksim Milyutin
committed
Migrate extansion to 9.6
1 parent fd0cdeb commit 6ce6354

File tree

6 files changed

+47
-20
lines changed

6 files changed

+47
-20
lines changed

src/hooks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ pathman_join_pathlist_hook(PlannerInfo *root,
169169
*/
170170
nest_path->path.rows = get_parameterized_joinrel_size(root,
171171
joinrel,
172-
outer->rows,
173-
inner->rows,
172+
outer,
173+
inner,
174174
extra->sjinfo,
175175
filtered_joinclauses);
176176

src/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "access/sysattr.h"
2323
#include "catalog/indexing.h"
2424
#include "catalog/pg_constraint.h"
25+
#include "catalog/pg_constraint_fn.h"
2526
#include "catalog/pg_inherits.h"
2627
#include "catalog/pg_inherits_fn.h"
2728
#include "catalog/pg_type.h"

src/nodes_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "postgres.h"
1717
#include "commands/explain.h"
1818
#include "optimizer/planner.h"
19+
#include "nodes/extensible.h"
1920

2021

2122
/*

src/partition_filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "postgres.h"
1818
#include "commands/explain.h"
1919
#include "optimizer/planner.h"
20-
20+
#include "nodes/extensible.h"
2121

2222
typedef struct
2323
{

src/pg_pathman.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,11 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
376376
Assert(childrel->rows > 0);
377377

378378
parent_rows += childrel->rows;
379-
parent_size += childrel->width * childrel->rows;
379+
parent_size += childrel->reltarget->width * childrel->rows;
380380
}
381381

382382
rel->rows = parent_rows;
383-
rel->width = rint(parent_size / parent_rows);
383+
rel->reltarget->width = rint(parent_size / parent_rows);
384384
rel->tuples = parent_rows;
385385
}
386386

@@ -423,15 +423,19 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
423423
childrel = build_simple_rel(root, childRTindex, RELOPT_OTHER_MEMBER_REL);
424424

425425
/* Copy targetlist */
426-
childrel->reltargetlist = NIL;
427-
foreach(lc, rel->reltargetlist)
426+
childrel->reltarget->exprs = NIL;
427+
childrel->reltarget->sortgrouprefs = (Index *) palloc(
428+
list_length(rel->reltarget->exprs) * sizeof(Index));
429+
foreach(lc, rel->reltarget->exprs)
428430
{
429431
Node *new_target;
430432

431433
node = (Node *) lfirst(lc);
432434
new_target = copyObject(node);
433435
change_varnos(new_target, rel->relid, childrel->relid);
434-
childrel->reltargetlist = lappend(childrel->reltargetlist, new_target);
436+
childrel->reltarget->exprs = lappend(childrel->reltarget->exprs,
437+
new_target);
438+
/* childrel->reltarget->sortgrouprefs[i++] = */
435439
}
436440

437441
/* Copy attr_needed & attr_widths */
@@ -1640,7 +1644,7 @@ set_plain_rel_size(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
16401644
* Test any partial indexes of rel for applicability. We must do this
16411645
* first since partial unique indexes can affect size estimates.
16421646
*/
1643-
check_partial_indexes(root, rel);
1647+
check_index_predicates(root, rel);
16441648

16451649
/* Mark rel with estimated output rows, width, etc */
16461650
set_baserel_size_estimates(root, rel);
@@ -1854,7 +1858,7 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
18541858
* if we have zero or one live subpath due to constraint exclusion.)
18551859
*/
18561860
if (subpaths_valid)
1857-
add_path(rel, (Path *) create_append_path(rel, subpaths, NULL));
1861+
add_path(rel, (Path *) create_append_path(rel, subpaths, NULL, 0));
18581862

18591863
/*
18601864
* Also build unparameterized MergeAppend paths based on the collected
@@ -1905,7 +1909,7 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
19051909

19061910
if (subpaths_valid)
19071911
add_path(rel, (Path *)
1908-
create_append_path(rel, subpaths, required_outer));
1912+
create_append_path(rel, subpaths, required_outer, 0));
19091913
}
19101914
}
19111915

@@ -2083,13 +2087,13 @@ generate_mergeappend_paths(PlannerInfo *root, RelOptInfo *rel,
20832087
{
20842088
Path *path;
20852089

2086-
path = (Path *) create_append_path(rel, startup_subpaths, NULL);
2090+
path = (Path *) create_append_path(rel, startup_subpaths, NULL, 0);
20872091
path->pathkeys = pathkeys;
20882092
add_path(rel, path);
20892093

20902094
if (startup_neq_total)
20912095
{
2092-
path = (Path *) create_append_path(rel, total_subpaths, NULL);
2096+
path = (Path *) create_append_path(rel, total_subpaths, NULL, 0);
20932097
path->pathkeys = pathkeys;
20942098
add_path(rel, path);
20952099
}
@@ -2103,14 +2107,14 @@ generate_mergeappend_paths(PlannerInfo *root, RelOptInfo *rel,
21032107
Path *path;
21042108

21052109
path = (Path *) create_append_path(rel,
2106-
list_reverse(startup_subpaths), NULL);
2110+
list_reverse(startup_subpaths), NULL, 0);
21072111
path->pathkeys = pathkeys;
21082112
add_path(rel, path);
21092113

21102114
if (startup_neq_total)
21112115
{
21122116
path = (Path *) create_append_path(rel,
2113-
list_reverse(total_subpaths), NULL);
2117+
list_reverse(total_subpaths), NULL, 0);
21142118
path->pathkeys = pathkeys;
21152119
add_path(rel, path);
21162120
}

src/runtime_merge_append.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "catalog/pg_collation.h"
1616
#include "miscadmin.h"
1717
#include "nodes/nodeFuncs.h"
18+
#include "nodes/plannodes.h"
1819
#include "optimizer/clauses.h"
1920
#include "optimizer/cost.h"
2021
#include "optimizer/planmain.h"
@@ -601,6 +602,27 @@ find_ec_member_for_tle(EquivalenceClass *ec,
601602
return NULL;
602603
}
603604

605+
/*
606+
* make_result
607+
* Build a Result plan node
608+
*/
609+
static Result *
610+
make_result(List *tlist,
611+
Node *resconstantqual,
612+
Plan *subplan)
613+
{
614+
Result *node = makeNode(Result);
615+
Plan *plan = &node->plan;
616+
617+
plan->targetlist = tlist;
618+
plan->qual = NIL;
619+
plan->lefttree = subplan;
620+
plan->righttree = NULL;
621+
node->resconstantqual = resconstantqual;
622+
623+
return node;
624+
}
625+
604626
static Plan *
605627
prepare_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree, List *pathkeys,
606628
Relids relids,
@@ -727,6 +749,7 @@ prepare_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree, List *pathkeys,
727749
EquivalenceMember *em = (EquivalenceMember *) lfirst(j);
728750
List *exprvars;
729751
ListCell *k;
752+
int varflag;
730753

731754
/*
732755
* We shouldn't be trying to sort by an equivalence class that
@@ -745,9 +768,8 @@ prepare_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree, List *pathkeys,
745768
continue;
746769

747770
sortexpr = em->em_expr;
748-
exprvars = pull_var_clause((Node *) sortexpr,
749-
PVC_INCLUDE_AGGREGATES,
750-
PVC_INCLUDE_PLACEHOLDERS);
771+
varflag = PVC_INCLUDE_AGGREGATES | PVC_INCLUDE_PLACEHOLDERS;
772+
exprvars = pull_var_clause((Node *) sortexpr, varflag);
751773
foreach(k, exprvars)
752774
{
753775
if (!tlist_member_ignore_relabel(lfirst(k), tlist))
@@ -771,8 +793,7 @@ prepare_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree, List *pathkeys,
771793
{
772794
/* copy needed so we don't modify input's tlist below */
773795
tlist = copyObject(tlist);
774-
lefttree = (Plan *) make_result(root, tlist, NULL,
775-
lefttree);
796+
lefttree = (Plan *) make_result(tlist, NULL, lefttree);
776797
}
777798

778799
/* Don't bother testing is_projection_capable_plan again */

0 commit comments

Comments
 (0)