| From: | Suraj Kharage <suraj(dot)kharage(at)enterprisedb(dot)com> |
|---|---|
| To: | Ajay Pal <ajay(dot)pal(dot)k(at)gmail(dot)com> |
| Cc: | Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Andrew Dunstan <andrew(at)dunslane(dot)net>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] Add support for INSERT ... SET syntax |
| Date: | 2026-04-01 04:28:20 |
| Message-ID: | CAF1DzPUHYf=zUSrrnT5C+YBjWr5KYEFhG_u1P-Xh_8gc_aYQiA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Thanks, Ajay for reporting this.
The issue is that the INSERT...SET grammar was incorrectly using
set_clause_list which includes the UPDATE-style
multi-column assignment syntax (col1, col2) = expr. This creates
MultiAssignRef nodes that are only valid in UPDATE contexts, not INSERT.
Fix this by changing the grammer rule.
Please find attached v2 patch with the above fix. I have also added support
for different column sets in multi-row inserts.
Thanks, Andrew for the offline discussion and help on this.
--
Thanks & Regards,
Suraj kharage,
enterprisedb.com <https://www.enterprisedb.com/>
On Tue, Mar 31, 2026 at 11:44 AM Ajay Pal <ajay(dot)pal(dot)k(at)gmail(dot)com> wrote:
> Hello all,
>
> I am reporting a server crash encountered while testing the patch
> provided by Suraj. The crash is consistently triggered by the query
> attached below.
>
> postgres=# INSERT INTO emp_test SET (empno,ename)=(SELECT 1,'aa');
>
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
> The connection to the server was lost. Attempting reset: Failed.
>
> Thanks
> Ajay
>
> On Mon, Mar 30, 2026 at 9:19 PM Álvaro Herrera <alvherre(at)kurilemu(dot)de>
> wrote:
> >
> > On 2026-Mar-30, Andrew Dunstan wrote:
> >
> > > Well, Suraj has kinda beaten me to it, but he didn't invent this
> syntax.
> > > Oracle did <
> https://oracle-base.com/articles/23/non-positional-insert-into-set-and-insert-into-by-name-clauses-23
> >
> > > and I believe there is a proposal to add it to the standard. (Unlike
> > > Suraj's, my WIP patch also supports the INSERT BY NAME variant.)
> >
> > Hmm, I don't see any WIP patch from you -- are you talking about this
> > patch from July 2019?
> >
> https://postgr.es/m/CA+A-St+NntBh2EGu3a0xbVxJFzaeEOn=Vn_V84OuhM59_HKarQ@mail.gmail.com
> >
> > Funnily enough, we have an even older proposal from 2016,
> > https://postgr.es/m/709e06c0-59c9-ccec-d216-21e38cb5ed61@joh.to
> >
> > It seems this is quite a popular missing feature, as Marko's patch was
> > also asked about in February 2019:
> > https://postgr.es/m/e58dd487-7ed4-3f95-c63c-24200ed768be@berkvens.net
> >
> > --
> > Álvaro Herrera Breisgau, Deutschland —
> https://www.EnterpriseDB.com/
> >
> >
>
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Add-support-for-INSERT-.-SET-syntax.patch | application/octet-stream | 34.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-04-01 04:56:53 | Re: [Proposal] Adding Log File Capability to pg_createsubscriber |
| Previous Message | Chao Li | 2026-04-01 03:57:00 | Re: Redundant/mis-use of _(x) gettext macro? |