Fix attribute mapping for COPY TO on partitioned tables.

Commit 4bea91f21f61 enabled COPY TO on a partitioned table to read
tuples from its partitions and mapped them to the root table's tuple
descriptor before output. However, it incorrectly built the attribute
map from the root table to the partition.

This commit fixes by building the attribute map from the partition to
the root table, ensuring that partition attributes are correctly
mapped to their corresponding root attributes.

Author: Chao Li <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/82f0135a2630cc4465a8a424e38faf0f4e92f421

Modified Files
--------------
src/backend/commands/copyto.c      |  4 ++--
src/test/regress/expected/copy.out | 11 +++++++++++
src/test/regress/sql/copy.sql      |  9 +++++++++
3 files changed, 22 insertions(+), 2 deletions(-)

Reply via email to