Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some more PG12 and PG13 code #6938

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 0 additions & 161 deletions src/import/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@
#include "compat/compat.h"
#include "planner.h"

#if PG_VERSION_NUM < 130003
static EquivalenceMember *find_ec_member_matching_expr(EquivalenceClass *ec, Expr *expr,
Relids relids);
static EquivalenceMember *find_computable_ec_member(PlannerInfo *root, EquivalenceClass *ec,
List *exprs, Relids relids,
bool require_parallel_safe);
#endif
static Node *replace_nestloop_params(PlannerInfo *root, Node *expr);
static Node *replace_nestloop_params_mutator(Node *node, PlannerInfo *root);
static Plan *inject_projection_plan(Plan *subplan, List *tlist, bool parallel_safe);
Expand Down Expand Up @@ -371,160 +364,6 @@ ts_get_variable_range(PlannerInfo *root, VariableStatData *vardata, Oid sortop,
return have_data;
}

#if PG_VERSION_NUM < 130003
/*
* find_ec_member_matching_expr
* Locate an EquivalenceClass member matching the given expr, if any;
* return NULL if no match.
*
* "Matching" is defined as "equal after stripping RelabelTypes".
* This is used for identifying sort expressions, and we need to allow
* binary-compatible relabeling for some cases involving binary-compatible
* sort operators.
*
* Child EC members are ignored unless they belong to given 'relids'.
*/
static EquivalenceMember *
find_ec_member_matching_expr(EquivalenceClass *ec, Expr *expr, Relids relids)
{
ListCell *lc;

/* We ignore binary-compatible relabeling on both ends */
while (expr && IsA(expr, RelabelType))
expr = ((RelabelType *) expr)->arg;

foreach (lc, ec->ec_members)
{
EquivalenceMember *em = (EquivalenceMember *) lfirst(lc);
Expr *emexpr;

/*
* We shouldn't be trying to sort by an equivalence class that
* contains a constant, so no need to consider such cases any further.
*/
if (em->em_is_const)
continue;

/*
* Ignore child members unless they belong to the requested rel.
*/
if (em->em_is_child && !bms_is_subset(em->em_relids, relids))
continue;

/*
* Match if same expression (after stripping relabel).
*/
emexpr = em->em_expr;
while (emexpr && IsA(emexpr, RelabelType))
emexpr = ((RelabelType *) emexpr)->arg;

if (equal(emexpr, expr))
return em;
}

return NULL;
}

/*
* is_exprlist_member
* Subroutine for find_computable_ec_member: is "node" in "exprs"?
*
* Per the requirements of that function, "exprs" might or might not have
* TargetEntry superstructure.
*/
static bool
is_exprlist_member(Expr *node, List *exprs)
{
ListCell *lc;

foreach (lc, exprs)
{
Expr *expr = (Expr *) lfirst(lc);

if (expr && IsA(expr, TargetEntry))
expr = ((TargetEntry *) expr)->expr;

if (equal(node, expr))
return true;
}
return false;
}

/*
* find_computable_ec_member
* Locate an EquivalenceClass member that can be computed from the
* expressions appearing in "exprs"; return NULL if no match.
*
* "exprs" can be either a list of bare expression trees, or a list of
* TargetEntry nodes. Either way, it should contain Vars and possibly
* Aggrefs and WindowFuncs, which are matched to the corresponding elements
* of the EquivalenceClass's expressions.
*
* Unlike find_ec_member_matching_expr, there's no special provision here
* for binary-compatible relabeling. This is intentional: if we have to
* compute an expression in this way, setrefs.c is going to insist on exact
* matches of Vars to the source tlist.
*
* Child EC members are ignored unless they belong to given 'relids'.
* Also, non-parallel-safe expressions are ignored if 'require_parallel_safe'.
*
* Note: some callers pass root == NULL for notational reasons. This is OK
* when require_parallel_safe is false.
*/
static EquivalenceMember *
find_computable_ec_member(PlannerInfo *root, EquivalenceClass *ec, List *exprs, Relids relids,
bool require_parallel_safe)
{
ListCell *lc;

foreach (lc, ec->ec_members)
{
EquivalenceMember *em = (EquivalenceMember *) lfirst(lc);
List *exprvars;
ListCell *lc2;

/*
* We shouldn't be trying to sort by an equivalence class that
* contains a constant, so no need to consider such cases any further.
*/
if (em->em_is_const)
continue;

/*
* Ignore child members unless they belong to the requested rel.
*/
if (em->em_is_child && !bms_is_subset(em->em_relids, relids))
continue;

/*
* Match if all Vars and quasi-Vars are available in "exprs".
*/
exprvars = pull_var_clause((Node *) em->em_expr,
PVC_INCLUDE_AGGREGATES | PVC_INCLUDE_WINDOWFUNCS |
PVC_INCLUDE_PLACEHOLDERS);
foreach (lc2, exprvars)
{
if (!is_exprlist_member(lfirst(lc2), exprs))
break;
}
list_free(exprvars);
if (lc2)
continue; /* we hit a non-available Var */

/*
* If requested, reject expressions that are not parallel-safe. We
* check this last because it's a rather expensive test.
*/
if (require_parallel_safe && !is_parallel_safe(root, (Node *) em->em_expr))
continue;

return em; /* found usable expression */
}

return NULL;
}
#endif

/*
* ts_make_sort --- basic routine to build a Sort plan node
*
Expand Down
2 changes: 0 additions & 2 deletions src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -3745,9 +3745,7 @@ process_altertable_end_subcmd(Hypertable *ht, Node *parsetree, ObjectAddress *ob
case AT_SetLogged:
case AT_SetStorage:
case AT_ColumnDefault:
#if PG_VERSION_NUM >= 120005
case AT_CookedColumnDefault:
#endif
case AT_SetNotNull:
case AT_CheckNotNull:
case AT_DropNotNull:
Expand Down
Loading