]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Check default partitions constraints while descending
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 8 Sep 2020 22:35:15 +0000 (19:35 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 8 Sep 2020 22:35:15 +0000 (19:35 -0300)
commitef1e1250e716056a240ecabc6f2a91c5956ed6c8
treeb4b4441c00dcc84f85b8b5a6ff89e6644ac28939
parent87483c7bb32059f203a3fa36b4ffa9070970fa03
Check default partitions constraints while descending

Partitioning tuple route code assumes that the partition chosen while
descending the partition hierarchy is always the correct one.  This is
true except when the partition is the default partition and another
partition has been added concurrently: the partition constraint changes
and we don't recheck it.  This can lead to tuples mistakenly being added
to the default partition that should have been rejected.

Fix by rechecking the default partition constraint while descending the
hierarchy.

An isolation test based on the reproduction steps described by Hao Wu
(with tweaks for extra coverage) is included.

Backpatch to 12, where this bug came in with 898e5e3290a7.

Reported by: Hao Wu <hawu@vmware.com>
Author: Amit Langote <amitlangote09@gmail.com>
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/CA+HiwqFqBmcSSap4sFnCBUEL_VfOMmEKaQ3gwUhyfa4c7J_-nA@mail.gmail.com
Discussion: https://postgr.es/m/DM5PR0501MB3910E97A9EDFB4C775CF3D75A42F0@DM5PR0501MB3910.namprd05.prod.outlook.com
src/backend/executor/execPartition.c
src/test/isolation/expected/partition-concurrent-attach.out [new file with mode: 0644]
src/test/isolation/isolation_schedule
src/test/isolation/specs/partition-concurrent-attach.spec [new file with mode: 0644]