]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix bogus ctid requirement for dummy-root partitioned targets
authorAmit Langote <amitlan@postgresql.org>
Fri, 23 Jan 2026 01:21:08 +0000 (10:21 +0900)
committerAmit Langote <amitlan@postgresql.org>
Fri, 23 Jan 2026 01:23:18 +0000 (10:23 +0900)
commitfab386f74888cb3cf4df9a20bcd24df2eb232bd2
tree84279f4b367d3331714ef8059fc9c15978d2b836
parent3f56de3aad1bcffae01dc2c22a41518a18d25d77
Fix bogus ctid requirement for dummy-root partitioned targets

ExecInitModifyTable() unconditionally required a ctid junk column even
when the target was a partitioned table. This led to spurious "could
not find junk ctid column" errors when all children were excluded and
only the dummy root result relation remained.

A partitioned table only appears in the result relations list when all
leaf partitions have been pruned, leaving the dummy root as the sole
entry. Assert this invariant (nrels == 1) and skip the ctid requirement.
Also adjust ExecModifyTable() to tolerate invalid ri_RowIdAttNo for
partitioned tables, which is safe since no rows will be processed in
this case.

Bug: #19099
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19099-e05dcfa022fe553d%40postgresql.org
Backpatch-through: 14
contrib/file_fdw/expected/file_fdw.out
contrib/file_fdw/sql/file_fdw.sql
src/backend/executor/nodeModifyTable.c