Skip to content

Commit

Permalink
PG16: Handle updates to make_restrictinfo function
Browse files Browse the repository at this point in the history
While fixing a bug in filtering of "cloned" outer-join quals, PG16 adds
3 new parameters to the make_restrictinfo function. Updated the compat
function to handle this change. This patch also cleans up the variants
of make_restrictinfo from other versions to make it clear which args are
passed.

postgres/postgres@991a3df227
  • Loading branch information
lkshminarayanan committed Aug 25, 2023
1 parent 9425402 commit 6fb3c3f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
63 changes: 57 additions & 6 deletions src/compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,39 +135,90 @@
*
* PG16 removed outerjoin_delayed, nullable_relids arguments from make_restrictinfo
* https://github.com/postgres/postgres/commit/b448f1c8d8
*
* PG16 adds three new parameter - has_clone, is_clone and incompatible_relids, as a
* part of fixing the filtering of "cloned" outer-join quals
* https://github.com/postgres/postgres/commit/991a3df227
*
*/

#if PG14_LT
#define pull_varnos_compat(root, expr) pull_varnos_new(root, expr)
#define make_simple_restrictinfo_compat(root, expr) \
make_restrictinfo_new(root, expr, true, false, false, 0, NULL, NULL, NULL)
#define make_restrictinfo_compat(root, a, b, c, d, e, f, g, h) \
make_restrictinfo_new(root, a, b, c, d, e, f, g, h)
#else
#define pull_varnos_compat(root, expr) pull_varnos(root, expr)
#define make_simple_restrictinfo_compat(root, clause) make_simple_restrictinfo(root, clause)
#if PG16_LT
#define make_restrictinfo_compat(root, a, b, c, d, e, f, g, h) \
make_restrictinfo(root, a, b, c, d, e, f, g, h)
#endif

#if PG14_LT
#define make_restrictinfo_compat(root, \
clause, \
is_pushed_down, \
has_clone, \
is_clone, \
outerjoin_delayed, \
pseudoconstant, \
security_level, \
required_relids, \
incompatible_relids, \
outer_relids, \
nullable_relids) \
make_restrictinfo_new(root, \
clause, \
is_pushed_down, \
outerjoin_delayed, \
pseudoconstant, \
security_level, \
required_relids, \
outer_relids, \
nullable_relids)
#elif PG16_LT
#define make_restrictinfo_compat(root, \
clause, \
is_pushed_down, \
has_clone, \
is_clone, \
outerjoin_delayed, \
pseudoconstant, \
security_level, \
required_relids, \
incompatible_relids, \
outer_relids, \
nullable_relids) \
make_restrictinfo(root, \
clause, \
is_pushed_down, \
outerjoin_delayed, \
pseudoconstant, \
security_level, \
required_relids, \
outer_relids, \
nullable_relids)
#else
#define make_restrictinfo_compat(root, \
clause, \
is_pushed_down, \
has_clone, \
is_clone, \
outerjoin_delayed, \
pseudoconstant, \
security_level, \
required_relids, \
incompatible_relids, \
outer_relids, \
nullable_relids) \
make_restrictinfo(root, \
clause, \
is_pushed_down, \
has_clone, \
is_clone, \
pseudoconstant, \
security_level, \
required_relids, \
incompatible_relids, \
outer_relids)
#endif
#endif

/* PG14 renames predefined roles
*
Expand Down
3 changes: 3 additions & 0 deletions src/planner/expand_hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,9 +1604,12 @@ propagate_join_quals(PlannerInfo *root, RelOptInfo *rel, CollectQualCtx *ctx)
true,
false,
false,
false,
false,
ctx->root->qual_security_level,
relids,
NULL,
NULL,
NULL);
ctx->restrictions = lappend(ctx->restrictions, restrictinfo);
/*
Expand Down
13 changes: 13 additions & 0 deletions tsl/src/fdw/data_node_scan_plan.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,28 @@ adjust_data_node_rel_attrs(PlannerInfo *root, RelOptInfo *data_node_rel, RelOptI
root->hasPseudoConstantQuals = true;
}
/* reconstitute RestrictInfo with appropriate properties */
bool hasClone = false;
bool isClone = false;
#if PG16_LT
/* both has_clone and is_clone are unused in versions less than PG16 */
(void) hasClone;
(void) isClone;
#else
hasClone = rinfo->has_clone;
isClone = rinfo->is_clone;
#endif
nodequals = lappend(nodequals,
make_restrictinfo_compat(root,
(Expr *) onecq,
rinfo->is_pushed_down,
hasClone,
isClone,
rinfo->outerjoin_delayed,
pseudoconstant,
rinfo->security_level,
NULL,
NULL,
NULL,
NULL));
}
}
Expand Down
3 changes: 3 additions & 0 deletions tsl/src/fdw/scan_plan.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,12 @@ foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel, GroupPathExtraDa
true,
false,
false,
false,
false,
root->qual_security_level,
grouped_rel->relids,
NULL,
NULL,
NULL);
if (ts_is_foreign_expr(root, grouped_rel, expr))
fpinfo->remote_conds = lappend(fpinfo->remote_conds, rinfo);
Expand Down

0 comments on commit 6fb3c3f

Please sign in to comment.