From: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
---|---|
To: | gareth(at)internetnz(dot)net(dot)nz |
Cc: | marko(at)joh(dot)to, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Implement INSERT SET syntax |
Date: | 2019-07-18 06:54:10 |
Message-ID: | 20190718.155410.04886080.horikyota.ntt@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello.
At Thu, 18 Jul 2019 11:30:04 +1200, Gareth Palmer <gareth(at)internetnz(dot)net(dot)nz> wrote in <D50A93EB-11F3-4ED2-8192-0328DF901BBA(at)internetnz(dot)net(dot)nz>
> Hi Marko,
>
> > On 17/07/2019, at 5:52 PM, Marko Tiikkaja <marko(at)joh(dot)to> wrote:
> >
> > On Wed, Jul 17, 2019 at 7:30 AM Gareth Palmer <gareth(at)internetnz(dot)net(dot)nz> wrote:
> > Attached is a patch that adds the option of using SET clause to specify
> > the columns and values in an INSERT statement in the same manner as that
> > of an UPDATE statement.
> >
> > Cool! Thanks for working on this, I'd love to see the syntax in PG.
> >
> > There was a brief discussion regarding INSERT SET on pgsql-hackers in late
> > August 2009 [1].
> >
> > There was also at least one slightly more recent adventure: https://www.postgresql.org/message-id/709e06c0-59c9-ccec-d216-21e38cb5ed61%40joh.to
> >
> > You might want to check that thread too, in case any of the criticism there applies to this patch as well.
>
> Thank-you for the pointer to that thread.
>
> I think my version avoids issue raised there by doing the conversion of the SET clause as part of the INSERT grammar rules.
If I'm not missing something, "SELECT <targetlist>" without
having FROM clause doesn't need to be tweaked. Thus
insert_set_clause is useless and all we need here would be
something like the following. (and the same for OVERRIDING.)
+ | SET set_clause_list from_clause
+ {
+ SelectStmt *n = makeNode(SelectStmt);
+ n->targetList = $2;
+ n->fromClause = $3;
+ $$ = makeNode(InsertStmt);
+ $$->selectStmt = (Node *)n;
+ $$->cols = $2;
+ }
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
From | Date | Subject | |
---|---|---|---|
Next Message | Etsuro Fujita | 2019-07-18 06:55:36 | Re: [HACKERS] advanced partition matching algorithm for partition-wise join |
Previous Message | Amit Kapila | 2019-07-18 06:40:26 | Re: SegFault on 9.6.14 |