diff options
author | David Rowley <drowley@postgresql.org> | 2019-06-05 18:28:38 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2019-06-05 18:28:38 +1200 |
commit | 56b3b3838284f53c83556592e60688522155f57f (patch) | |
tree | 7a47099711def269892733512fc5afbeb2ee8a2b /src/backend/commands/copy.c | |
parent | f7e954ad1cf99a65b1785d999058898a6d56e014 (diff) |
Fix incorrect index behavior in COPY FROM with partitioned tables
86b85044e rewrote how COPY FROM works to allow multiple tuple buffers to
exist to once thus allowing multi-inserts to be used in more cases with
partitioned tables. That commit neglected to update the estate's
es_result_relation_info when flushing the insert buffer to the partition
making it possible for the index tuples to be added into an index on the
wrong partition.
Fix this and also add an Assert in ExecInsertIndexTuples to help ensure
that we never make this mistake again.
Reported-by: Haruka Takatsuka
Author: Ashutosh Sharma
Discussion: https://postgr.es/m/15832-b1bf336a4ee246b5@postgresql.org
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r-- | src/backend/commands/copy.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index eca0be1ff96..2593732c16e 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -2446,6 +2446,9 @@ CopyMultiInsertBufferFlush(CopyMultiInsertInfo *miinfo, ResultRelInfo *resultRelInfo = buffer->resultRelInfo; TupleTableSlot **slots = buffer->slots; + /* Set es_result_relation_info to the ResultRelInfo we're flushing. */ + estate->es_result_relation_info = resultRelInfo; + /* * Print error context information correctly, if one of the operations * below fail. |