Re: multi-row INSERT broken with a sublink in a target column subscript

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: multi-row INSERT broken with a sublink in a target column subscript
Date: 2026-11-04 07:24:58
Message-ID: CA+HiwqHSsvy-XjnpXW+ktXZsgDn+GCsn5A42Vj846Wq6j269Bg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Nov 4, 2026 at 12:06 PM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> Hi Amit,
>
> The fix looks right to me. One small thing in the test. Both
> subscripts evaluate to 1, so it only sets f2[1]. Maybe use
> (1 IS NOT NULL)::int + 1 and add RETURNING f2, so the output
> shows both elements:
>
> insert into inserttest (f2[(select 1)], f2[(1 IS NOT NULL)::int + 1])
> values (9,10), (11,12) returning f2;

Ah, my bad I didn't write it like that to begin with. Done like that.

I decided not to go with with Chao's idea of using strip_indirection
to skip the copy in this patch in order to keep things simple. I am
not sure if being clever won't cause issues later. Thanks for the
review though.

I'll push the attached updated patch barring objections.

--
Thanks, Amit Langote

Attachment Content-Type Size
v2-0001-Fix-multi-row-INSERT-with-a-sublink-in-a-target-c.patch application/octet-stream 3.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-11-04 07:30:24 Re: Hash index corruption and CLOG lookup errors from checkpoint races
Previous Message Tatsuo Ishii 2026-11-04 07:24:01 Re: nodeWindowAgg.c IGNORE NULLS abs overflow