summaryrefslogtreecommitdiff
path: root/src/backend/catalog/partition.c
diff options
context:
space:
mode:
authorTom Lane2019-12-25 20:44:15 +0000
committerTom Lane2019-12-25 20:44:15 +0000
commitbb4114a4e2c65f27931cc074214c051dba2876c3 (patch)
treef197bcc85c7479e20905e9f821893d5c49eb67b3 /src/backend/catalog/partition.c
parent42f74f49367bee1d3da28c4b383faec29364f320 (diff)
Allow whole-row Vars to be used in partitioning expressions.
In the wake of commit 5b9312378, there's no particular reason for this restriction (previously, it was problematic because of the implied rowtype reference). A simple constraint on a whole-row Var probably isn't that useful, but conceivably somebody would want to pass one to a function that extracts a partitioning key. Besides which, we're expending much more code to enforce the restriction than we save by having it, since the latter quantity is now zero. So drop the restriction. Amit Langote Discussion: https://postgr.es/m/CA+HiwqFUzjfj9HEsJtYWcr1SgQ_=iCAvQ=O2Sx6aQxoDu4OiHw@mail.gmail.com
Diffstat (limited to 'src/backend/catalog/partition.c')
-rw-r--r--src/backend/catalog/partition.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index 5f85b9b99ca..3c2bec25b9e 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -181,17 +181,14 @@ index_get_partition(Relation partition, Oid indexId)
}
/*
- * map_partition_varattnos - maps varattno of any Vars in expr from the
- * attno's of 'from_rel' to the attno's of 'to_rel' partition, each of which
- * may be either a leaf partition or a partitioned table, but both of which
- * must be from the same partitioning hierarchy.
+ * map_partition_varattnos - maps varattnos of all Vars in 'expr' (that have
+ * varno 'fromrel_varno') from the attnums of 'from_rel' to the attnums of
+ * 'to_rel', each of which may be either a leaf partition or a partitioned
+ * table, but both of which must be from the same partitioning hierarchy.
*
- * Even though all of the same column names must be present in all relations
- * in the hierarchy, and they must also have the same types, the attnos may
- * be different.
- *
- * If found_whole_row is not NULL, *found_whole_row returns whether a
- * whole-row variable was found in the input expression.
+ * We need this because even though all of the same column names must be
+ * present in all relations in the hierarchy, and they must also have the
+ * same types, the attnums may be different.
*
* Note: this will work on any node tree, so really the argument and result
* should be declared "Node *". But a substantial majority of the callers
@@ -199,14 +196,12 @@ index_get_partition(Relation partition, Oid indexId)
*/
List *
map_partition_varattnos(List *expr, int fromrel_varno,
- Relation to_rel, Relation from_rel,
- bool *found_whole_row)
+ Relation to_rel, Relation from_rel)
{
- bool my_found_whole_row = false;
-
if (expr != NIL)
{
AttrMap *part_attmap;
+ bool found_whole_row;
part_attmap = build_attrmap_by_name(RelationGetDescr(to_rel),
RelationGetDescr(from_rel));
@@ -214,12 +209,10 @@ map_partition_varattnos(List *expr, int fromrel_varno,
fromrel_varno, 0,
part_attmap,
RelationGetForm(to_rel)->reltype,
- &my_found_whole_row);
+ &found_whole_row);
+ /* Since we provided a to_rowtype, we may ignore found_whole_row. */
}
- if (found_whole_row)
- *found_whole_row = my_found_whole_row;
-
return expr;
}