aboutsummaryrefslogtreecommitdiff
path: root/src/backend/catalog/partition.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/catalog/partition.c')
-rw-r--r--src/backend/catalog/partition.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index 9d50efb6a04..dcc7f8af27c 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -898,16 +898,20 @@ get_qual_from_partbound(Relation rel, Relation parent,
* We must allow for cases where physical attnos of a partition can be
* different from the parent's.
*
+ * If found_whole_row is not NULL, *found_whole_row returns whether a
+ * whole-row variable was found in the input expression.
+ *
* 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
* are working on Lists, so it's less messy to do the casts internally.
*/
List *
map_partition_varattnos(List *expr, int target_varno,
- Relation partrel, Relation parent)
+ Relation partrel, Relation parent,
+ bool *found_whole_row)
{
AttrNumber *part_attnos;
- bool found_whole_row;
+ bool my_found_whole_row;
if (expr == NIL)
return NIL;
@@ -919,10 +923,10 @@ map_partition_varattnos(List *expr, int target_varno,
target_varno, 0,
part_attnos,
RelationGetDescr(parent)->natts,
- &found_whole_row);
- /* There can never be a whole-row reference here */
+ RelationGetForm(partrel)->reltype,
+ &my_found_whole_row);
if (found_whole_row)
- elog(ERROR, "unexpected whole-row reference found in partition key");
+ *found_whole_row = my_found_whole_row;
return expr;
}
@@ -1783,6 +1787,7 @@ generate_partition_qual(Relation rel)
List *my_qual = NIL,
*result = NIL;
Relation parent;
+ bool found_whole_row;
/* Guard against stack overflow due to overly deep partition tree */
check_stack_depth();
@@ -1825,7 +1830,11 @@ generate_partition_qual(Relation rel)
* in it to bear this relation's attnos. It's safe to assume varno = 1
* here.
*/
- result = map_partition_varattnos(result, 1, rel, parent);
+ result = map_partition_varattnos(result, 1, rel, parent,
+ &found_whole_row);
+ /* There can never be a whole-row reference here */
+ if (found_whole_row)
+ elog(ERROR, "unexpected whole-row reference found in partition key");
/* Save a copy in the relcache */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);