When looking at whether there exist other sites in the parser that are
like bug #19786, Claude found $subject.

CREATE TABLE ta (a int[]);
INSERT INTO ta (a[(SELECT 1)]) VALUES (1), (2);
ERROR:  unexpected non-SELECT command in SubLink

The problem is that transformInsertStmt() transforms the target
columns' indirection once per VALUES row without copying it, while
transformSubLink() modifies the raw SubLink in place.

a[(1 IS NULL)::int + 1] fails too, like this:

INSERT INTO ta (a[(1 IS NULL)::int + 1]) VALUES (1), (2);
ERROR:  unrecognized node type: 7

Attached patch fixes this.

-- 
Thanks, Amit Langote

Attachment: v1-0001-Fix-multi-row-INSERT-with-a-sublink-in-a-target-c.patch
Description: Binary data

Reply via email to