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-11 08:23:20
Message-ID: CA+HiwqFJ29LB5txVx-brdRWHxHkfu4-Po1rV9pF=MoC3E8Vhdg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 4, 2026 at 4:24 PM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> 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.

FTR, this was pushed and back-patched. 667243c02d in master.

--
Thanks, Amit Langote

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-11-11 08:26:51 Re: [PATCH] pg_input_is_valid() reuses the first type name inside a PL/pgSQL loop
Previous Message Chao Li 2026-11-11 08:04:27 Re: [PATCH] pg_input_is_valid() reuses the first type name inside a PL/pgSQL loop