Re: [PATCH] Implement INSERT SET syntax

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, Gareth Palmer <gareth(at)internetnz(dot)net(dot)nz>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Implement INSERT SET syntax
Date: 2019-11-01 18:00:47
Message-ID: CAL9smLAsgNGFFOCZZmU+_H-Lyx76R-1OqUr2WQZLuDtQTUkbCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 1, 2019 at 6:31 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Sun, Aug 18, 2019 at 11:00 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Perhaps the way to resolve Peter's objection is to make the syntax
> > more fully like UPDATE:
> >
> > INSERT INTO target SET c1 = x, c2 = y+z, ... FROM tables-providing-x-y-z
> >
> > (with the patch as-submitted corresponding to the case with an empty
> > FROM clause, hence no variables in the expressions-to-be-assigned).
> >
> > Of course, this is not functionally distinct from
> >
> > INSERT INTO target(c1,c2,...) SELECT x, y+z, ... FROM
> tables-providing-x-y-z
> >
> > and it's fair to question whether it's worth supporting a nonstandard
> > syntax just to allow the target column names to be written closer to
> > the expressions-to-be-assigned.
>
> For what it's worth, I think this would be useful enough to justify
> its existence. Back in days of yore when dragons roamed the earth and
> I wrote database-driven applications instead of hacking on the
> database itself, I often wondered why I had to write two
> completely-different looking SQL statements, one to insert the data
> which a user had entered into a webform into the database, and another
> to update previously-entered data. This feature would allow those
> queries to be written in the same way, which would have pleased me,
> back in the day.
>

I still do, and this would be a big help. I don't care if it's
non-standard.

.m

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Verite 2019-11-01 18:18:13 Re: ICU for global collation
Previous Message Andrew Dunstan 2019-11-01 18:00:27 Re: Allow superuser to grant passwordless connection rights on postgres_fdw