Fix tuple routing in cases where tuple descriptors don't match.
Robert Haas <rhaas@postgresql.org>
Fix tuple routing in cases where tuple descriptors don't match. The previous coding failed to work correctly when we have a multi-level partitioned hierarchy where tables at successive levels have different attribute numbers for the partition key attributes. To fix, have each PartitionDispatch object store a standalone TupleTableSlot initialized with the TupleDesc of the corresponding partitioned table, along with a TupleConversionMap to map tuples from the its parent's rowtype to own rowtype. After tuple routing chooses a leaf partition, we must use the leaf partition's tuple descriptor, not the root table's. To that end, a dedicated TupleTableSlot for tuple routing is now allocated in EState. Amit Langote
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/catalog/partition.c | modified | +61 −13 |
| src/backend/commands/copy.c | modified | +29 −2 |
| src/backend/executor/nodeModifyTable.c | modified | +27 −0 |
| src/include/catalog/partition.h | modified | +7 −0 |
| src/include/nodes/execnodes.h | modified | +3 −0 |
| src/test/regress/expected/insert.out | modified | +37 −0 |
| src/test/regress/sql/insert.sql | modified | +26 −0 |