Skip to content

Commit cfbecf8

Browse files
committed
Enforce child constraints during COPY TO a partitioned table.
The previous coding inadvertently checked the constraints for the partitioned table rather than the target partition, which could lead to data in a partition that fails to satisfy some constraint on that partition. This problem seems to date back to when table partitioning was introduced; prior to that, there was only one target table for a COPY, so the problem didn't occur, and the code just didn't get updated. Etsuro Fujita, reviewed by Amit Langote and Ashutosh Bapat Discussion: https://postgr.es/message-id/5ABA4074.1090500%40lab.ntt.co.jp
1 parent 870d896 commit cfbecf8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/commands/copy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,8 @@ CopyFrom(CopyState cstate)
27092709
check_partition_constr = false;
27102710

27112711
/* Check the constraints of the tuple */
2712-
if (cstate->rel->rd_att->constr || check_partition_constr)
2712+
if (resultRelInfo->ri_RelationDesc->rd_att->constr ||
2713+
check_partition_constr)
27132714
ExecConstraints(resultRelInfo, slot, estate, true);
27142715

27152716
if (useHeapMultiInsert)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy