> On Oct 28, 2026, at 08:42, Amit Langote <[email protected]> wrote:
>
> 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
> <v1-0001-Fix-multi-row-INSERT-with-a-sublink-in-a-target-c.patch>
The fix looks correct to me. I just have one nit.
When strip_indirection is false, we're building the final target list, so it
should be safe to use col->indirection directly, since it won't be transformed
again. Instead of unconditionally calling copyObject(), maybe we can do:
strip_indirection ? copyObject(col->indirection) : col->indirection
I tried this change locally, and the new test case still passes.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/