pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix multi-row INSERT with a sublink in a target column subscript
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix multi-row INSERT with a sublink in a target column subscript
@ 2026-11-04 23:17 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Amit Langote @ 2026-11-04 23:17 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.evan.chao@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9e77656a91f4df3f584329aba9fdfc5ca6704d28

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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix multi-row INSERT with a sublink in a target column subscript
@ 2026-11-04 23:17 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Amit Langote @ 2026-11-04 23:17 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.evan.chao@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/861a9c4026e6c99fbb589d20fe0b9304ef99433c

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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix multi-row INSERT with a sublink in a target column subscript
@ 2026-11-04 23:18 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Amit Langote @ 2026-11-04 23:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.evan.chao@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2dd680013e75e04e510a48968439ee704c6d456e

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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix multi-row INSERT with a sublink in a target column subscript
@ 2026-11-04 23:18 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Amit Langote @ 2026-11-04 23:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.evan.chao@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f116737684c28526e90f262098027fb7ddb518cd

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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix multi-row INSERT with a sublink in a target column subscript
@ 2026-11-04 23:18 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Amit Langote @ 2026-11-04 23:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.evan.chao@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fa0806647f5ffeb3c4536e218b8f2f4161ce3477

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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix multi-row INSERT with a sublink in a target column subscript
@ 2026-11-04 23:18 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Amit Langote @ 2026-11-04 23:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.evan.chao@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix multi-row INSERT with a sublink in a target column subscript
@ 2026-11-04 23:19 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Amit Langote @ 2026-11-04 23:19 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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.evan.chao@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ba3115d8389657b199f38244c429ebcfe2f77ed1

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(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2026-11-04 23:19 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 23:17 pgsql: Fix multi-row INSERT with a sublink in a target column subscript Amit Langote <amitlan@postgresql.org>
2026-11-04 23:17 pgsql: Fix multi-row INSERT with a sublink in a target column subscript Amit Langote <amitlan@postgresql.org>
2026-11-04 23:18 pgsql: Fix multi-row INSERT with a sublink in a target column subscript Amit Langote <amitlan@postgresql.org>
2026-11-04 23:18 pgsql: Fix multi-row INSERT with a sublink in a target column subscript Amit Langote <amitlan@postgresql.org>
2026-11-04 23:18 pgsql: Fix multi-row INSERT with a sublink in a target column subscript Amit Langote <amitlan@postgresql.org>
2026-11-04 23:18 pgsql: Fix multi-row INSERT with a sublink in a target column subscript Amit Langote <amitlan@postgresql.org>
2026-11-04 23:19 pgsql: Fix multi-row INSERT with a sublink in a target column subscript Amit Langote <amitlan@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox