mirror of https://github.com/citusdata/citus.git
Remove ExprMentionsPartitionColumn function for partition column reference checks
parent
49425b7778
commit
4d744ef114
|
@ -108,9 +108,6 @@ static void ProcessEntryPair(TargetEntry *insertEntry, TargetEntry *selectEntry,
|
|||
Form_pg_attribute attr, int targetEntryIndex,
|
||||
List **projectedEntries, List **nonProjectedEntries);
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
||||
static bool ExprMentionsPartitionColumn(Node *node, Query *query);
|
||||
#endif
|
||||
|
||||
/* depth of current insert/select planner. */
|
||||
static int insertSelectPlannerLevel = 0;
|
||||
|
@ -1426,79 +1423,6 @@ InsertPartitionColumnMatchesSelect(Query *query, RangeTblEntry *insertRte,
|
|||
}
|
||||
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
||||
|
||||
/*
|
||||
* ExprMentionsPartitionColumn
|
||||
*
|
||||
* Return true iff `node` ultimately resolves to the partition column of
|
||||
* *any* distributed table referenced by `query`.
|
||||
*
|
||||
* • Understands OUTER_VAR indirection (PG ≥ 17)
|
||||
* • Understands synthetic RTE_GROUP entries (PG ≥ 18)
|
||||
* • Falls back to original logic for PG 15/16 automatically
|
||||
*/
|
||||
static bool
|
||||
ExprMentionsPartitionColumn(Node *node, Query *query)
|
||||
{
|
||||
if (node == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsA(node, Var))
|
||||
{
|
||||
Var *v = (Var *) node;
|
||||
|
||||
/* Follow OUTER_VAR → target-list indirection, if present */
|
||||
if (v->varno == OUTER_VAR)
|
||||
{
|
||||
TargetEntry *tle = get_tle_by_resno(query->targetList, v->varattno);
|
||||
return tle && ExprMentionsPartitionColumn((Node *) tle->expr, query);
|
||||
}
|
||||
|
||||
/* Sanity-check varno */
|
||||
if (v->varno <= 0 || v->varno > list_length(query->rtable))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
RangeTblEntry *rte = rt_fetch(v->varno, query->rtable);
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
||||
|
||||
/* Synthetic GROUP RTE – examine its expressions instead */
|
||||
if (rte->rtekind == RTE_GROUP && rte->groupexprs)
|
||||
{
|
||||
ListCell *lc;
|
||||
foreach(lc, rte->groupexprs)
|
||||
if (ExprMentionsPartitionColumn((Node *) lfirst(lc), query))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Real table? — compare against its dist key */
|
||||
if (rte->rtekind == RTE_RELATION && HasDistributionKey(rte->relid))
|
||||
{
|
||||
Var *partcol = DistPartitionKey(rte->relid);
|
||||
return partcol && partcol->varattno == v->varattno;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Recurse through any other node type */
|
||||
return expression_tree_walker(node,
|
||||
ExprMentionsPartitionColumn,
|
||||
(void *) query);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* CreateNonPushableInsertSelectPlan creates a query plan for a SELECT into a
|
||||
* distributed table. The query plan can also be executed on a worker in MX.
|
||||
|
|
Loading…
Reference in New Issue