Re: [HACKERS] extension for sql update

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Susanne Ebrecht <miracee(at)miracee(dot)de>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] extension for sql update
Date: 2006-07-31 00:20:17
Message-ID: 200607302020.18041.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Thursday 27 July 2006 09:28, Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > > Tom Lane wrote:
> > >> UPDATE mytab SET (foo, bar, baz) =
> > >> (SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);
> > >
> > > That UPDATE example is interesting because I remember when using
> > > Informix that I had to do a separate SELECT statement for each UPDATE
> > > column I wanted to update. I didn't realize that you could group
> > > columns and assign them from a single select --- clearly that is a
> > > powerful syntax we should support some day.
> >
> > No question. The decision at hand is whether we want to look like
> > we support it, when we don't yet. I'd vote not, because I think the
> > main use-case for the row-on-the-left syntax is exactly this, and
> > so I fear people will just get frustrated if they see it in the
> > syntax synopsis and try to use it.
>

I'm not a big fan of implementing partial solutions (remember "left-joins are
not implemented messages" :-) way back when) , however in my experience with
this form of the update command, the primary usage is not to use a subselect
to derive the values, but to make it easier to generate sql, using a single
update statement, based on an array of passed in values (in languages like
perl/php/etc...). This solution would solve that problem for us, so I would
lean toward including it. I would be interested in hearing from actual users
who really need the subselect version though, but right now my thinking is
that group is a small minority of who would benefit from this version of the
update command.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2006-07-31 00:38:30 Re: [HACKERS] extension for sql update
Previous Message David Fetter 2006-07-31 00:03:13 Re: request: support of array in plperl OUT arguments

Browse pgsql-patches by date

  From Date Subject
Next Message Rod Taylor 2006-07-31 00:38:30 Re: [HACKERS] extension for sql update
Previous Message Gavin Sherry 2006-07-31 00:17:12 READ ONLY transaction documentation error