1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Fix for dropped columns in a partitioned table's default partition

We forgot to map column numbers to/from the default partition for
various operations, leading to valid cases failing with spurious
errors, such as
ERROR:  attribute N of type some_partition has been dropped

It was also possible that the search for conflicting rows in the default
partition when attaching another partition would fail to detect some.
Secondarily, it was also possible that such a search should be skipped
(because the constraint was implied) but wasn't.

Fix all this by mapping column numbers when necessary.

Reported by: Daniel Wilches
Author: Amit Langote
Discussion: https://postgr.es/m/15873-8c61945d6b3ef87c@postgresql.org
This commit is contained in:
Alvaro Herrera
2019-06-28 14:51:08 -04:00
parent 74b7cc8c02
commit 23cccb17fe
6 changed files with 70 additions and 7 deletions

View File

@ -15682,6 +15682,13 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
defaultrel = table_open(defaultPartOid, NoLock);
defPartConstraint =
get_proposed_default_constraint(partBoundConstraint);
/*
* Map the Vars in the constraint expression from rel's attnos to
* defaultrel's.
*/
defPartConstraint =
map_partition_varattnos(defPartConstraint,
1, defaultrel, rel, NULL);
QueuePartitionConstraintValidation(wqueue, defaultrel,
defPartConstraint, true);