Skip to content

Commit 29ab1e2

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 c00c4c5 commit 29ab1e2

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
@@ -2744,7 +2744,8 @@ CopyFrom(CopyState cstate)
27442744
check_partition_constr = false;
27452745

27462746
/* Check the constraints of the tuple */
2747-
if (cstate->rel->rd_att->constr || check_partition_constr)
2747+
if (resultRelInfo->ri_RelationDesc->rd_att->constr ||
2748+
check_partition_constr)
27482749
ExecConstraints(resultRelInfo, slot, estate);
27492750

27502751
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