aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/copy.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2018-04-06 11:42:28 -0400
committerRobert Haas <rhaas@postgresql.org>2018-04-06 11:52:38 -0400
commit29ab1e24a6a77bf112eba97b2873dab5a19c6cf1 (patch)
tree157e84ab660d2412a9980fcf18a1cda774c57c9d /src/backend/commands/copy.c
parentc00c4c57b04652fc8123f0a6d87314c0936745f3 (diff)
downloadpostgresql-29ab1e24a6a77bf112eba97b2873dab5a19c6cf1.tar.gz
postgresql-29ab1e24a6a77bf112eba97b2873dab5a19c6cf1.zip
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
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r--src/backend/commands/copy.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 5d46c9889dd..00b64e53204 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2744,7 +2744,8 @@ CopyFrom(CopyState cstate)
check_partition_constr = false;
/* Check the constraints of the tuple */
- if (cstate->rel->rd_att->constr || check_partition_constr)
+ if (resultRelInfo->ri_RelationDesc->rd_att->constr ||
+ check_partition_constr)
ExecConstraints(resultRelInfo, slot, estate);
if (useHeapMultiInsert)