| From: | Amit Langote <amitlan(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix multi-row INSERT with a sublink in a target column subscript |
| Date: | 2026-11-04 23:18:53 |
| Message-ID: | E1xOkFq-00000000EJF-0434@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix multi-row INSERT with a sublink in a target column subscript
For INSERT ... VALUES with more than one row, transformInsertStmt()
calls transformInsertRow() once for each VALUES row and once more for
the final targetlist, and each call transformed the same raw
indirection from the target column list. That doesn't work for
sublinks, because transformSubLink() replaces the raw subselect with
its analyzed Query, so the second pass failed with "unexpected
non-SELECT command in SubLink". Other nodes that are transformed in
place, such as NullTest, failed with "unrecognized node type".
Fix by giving each transformation its own copy of the indirection.
Claude found this issue when reviewing another bug.
Discussion: https://postgr.es/m/CA+HiwqHCZLZV_20nz3fQX+1=vyFLDMbG0_3wY=QujNKZWts0nw@mail.gmail.com
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Shihao Zhong <zhong950419(at)gmail(dot)com>
Backpatch-through: 14
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/667243c02ddd246705c383a62a511c2cbcc2fb7c
Modified Files
--------------
src/backend/parser/analyze.c | 8 +++++++-
src/test/regress/expected/insert.out | 10 ++++++++++
src/test/regress/sql/insert.sql | 4 ++++
3 files changed, 21 insertions(+), 1 deletion(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-11-04 23:19:07 | pgsql: Fix multi-row INSERT with a sublink in a target column subscript |
| Previous Message | Amit Langote | 2026-11-04 23:18:40 | pgsql: Fix multi-row INSERT with a sublink in a target column subscript |