]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix attribute mapping for COPY TO on partitioned tables.
authorMasahiko Sawada <msawada@postgresql.org>
Thu, 14 May 2026 17:32:34 +0000 (10:32 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Thu, 14 May 2026 17:32:34 +0000 (10:32 -0700)
commit82f0135a2630cc4465a8a424e38faf0f4e92f421
treecc664f9032d9decb32f6bd7bc5e862a55175fad9
parentce146621f7860d2e19c509f1466feca3bf777678
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 <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/85EA70F3-C3DB-477B-B856-EA569FDAAE7C@gmail.com
src/backend/commands/copyto.c
src/test/regress/expected/copy.out
src/test/regress/sql/copy.sql