Re: [PATCHES] extension for sql update

Lists: pgsql-hackerspgsql-patches
From: Susanne Ebrecht <miracee(at)miracee(dot)de>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: extension for sql update
Date: 2006-07-19 14:13:36
Message-ID: 1153318416.4814.12.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hi,

here is a patch that extends update syntax following the sql standard.
The patch includes sgml documentation, too.

For example:

UPDATE table SET (col1, col2, ...) = (val1, val2, ...),
(colm, coln, ...) = (valm, valn, ...), ...;

Susanne

Attachment Content-Type Size
sql_standard_update_syntax.patch text/x-patch 6.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Susanne Ebrecht <miracee(at)miracee(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: extension for sql update
Date: 2006-07-26 20:58:44
Message-ID: 18012.1153947524@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Susanne Ebrecht <miracee(at)miracee(dot)de> writes:
> here is a patch that extends update syntax following the sql standard.
> The patch includes sgml documentation, too.

> UPDATE table SET (col1, col2, ...) = (val1, val2, ...),
> (colm, coln, ...) = (valm, valn, ...), ...;

This is a cute hack, but it does only a small part of what I think the
spec says.

In the first place, the SQL syntax is pretty clear that you can combine
simple and multiple assignment in the same UPDATE:

<update statement: searched> ::=
UPDATE <target table>
SET <set clause list>
[ WHERE <search condition> ]

<set clause list> ::=
<set clause> [ { <comma> <set clause> }... ]

<set clause> ::=
<multiple column assignment>
| <set target> <equals operator> <update source>

<multiple column assignment> ::=
<set target list> <equals operator> <assigned row>

<set target list> ::=
<left paren> <set target> [ { <comma> <set target> } ... ] <right paren>

The patch doesn't do that, but it wouldn't be too hard to fix. The more
serious problem is that

<assigned row> ::= <contextually typed row value expression>

and <contextually typed row value expression> is supposed to be pretty
much anything that can generate a row. The patch as you have it
provides nothing more than syntactic sugar for something people can do
anyway. The reason people want this syntax is that they expect to be
able to write, say,

UPDATE mytab SET (foo, bar, baz) =
(SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);

and with something like that you can't break apart the row-valued
expression in the grammar. So in reality the feature has to propagate
much further into the backend than this.

regards, tom lane


From: Susanne Ebrecht <miracee(at)miracee(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: extension for sql update
Date: 2006-07-27 09:36:35
Message-ID: 1153992995.4811.24.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Am Mittwoch, den 26.07.2006, 16:58 -0400 schrieb Tom Lane:
> Susanne Ebrecht <miracee(at)miracee(dot)de> writes:

> This is a cute hack, but it does only a small part of what I think the
> spec says.
Thank you for compliment.

>
> In the first place, the SQL syntax is pretty clear that you can combine
> simple and multiple assignment in the same UPDATE:

Ups, I asked about mixed syntax and I missunderstood the answer (I
thougt there is nothing spezified about mixed syntax). But fixing this,
seems not to be difficult.

> The patch doesn't do that, but it wouldn't be too hard to fix. The more
> serious problem is that
>
> <assigned row> ::= <contextually typed row value expression>
>
> and <contextually typed row value expression> is supposed to be pretty
> much anything that can generate a row. The patch as you have it
> provides nothing more than syntactic sugar for something people can do
> anyway. The reason people want this syntax is that they expect to be
> able to write, say,
>
> UPDATE mytab SET (foo, bar, baz) =
> (SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);
>
> and with something like that you can't break apart the row-valued
> expression in the grammar. So in reality the feature has to propagate
> much further into the backend than this.

This seems to be difficult and I'm not sure this could be done until
feature freeze. We could provide the mixed update syntax and leave the
typed row value expression for the next release. Do you agree?

regards
Susanne Ebrecht


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Susanne Ebrecht <miracee(at)miracee(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: extension for sql update
Date: 2006-07-27 12:30:21
Message-ID: 5490.1154003421@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Susanne Ebrecht <miracee(at)miracee(dot)de> writes:
> ... We could provide the mixed update syntax and leave the
> typed row value expression for the next release. Do you agree?

I don't really see the point --- the patch won't provide any new
functionality in anything like its current form, because you can
always just write the separate expressions in the simple one to
one way. If we do offer the row-on-the-left syntax then people
will try to put sub-selects on the right, and won't get anything
beyond an unhelpful "syntax error" message. So my vote would be
to leave it alone until we have a more complete implementation.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Susanne Ebrecht <miracee(at)miracee(dot)de>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: extension for sql update
Date: 2006-07-27 13:11:48
Message-ID: 200607271311.k6RDBmH27064@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> much anything that can generate a row. The patch as you have it
> provides nothing more than syntactic sugar for something people can do
> anyway. The reason people want this syntax is that they expect to be
> able to write, say,
>
> UPDATE mytab SET (foo, bar, baz) =
> (SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);
>
> and with something like that you can't break apart the row-valued
> expression in the grammar. So in reality the feature has to propagate
> much further into the backend than this.

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.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Susanne Ebrecht <miracee(at)miracee(dot)de>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: extension for sql update
Date: 2006-07-27 13:17:20
Message-ID: 6000.1154006240@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

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.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Susanne Ebrecht <miracee(at)miracee(dot)de>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: extension for sql update
Date: 2006-07-27 13:28:05
Message-ID: 200607271328.k6RDS5519882@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

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.

Agreed. My guess is that a soluion that allows SELECT to return
multiple values is going to be in another area of the code, and will
require us to remove this code once that is done.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Jim Nasby <jnasby(at)pervasive(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Susanne Ebrecht <miracee(at)miracee(dot)de>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] extension for sql update
Date: 2006-07-27 15:00:04
Message-ID: 9EA3B62F-D3BC-44B4-885A-ACCD9EFB4D81@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Jul 27, 2006, at 7:30 AM, Tom Lane wrote:
> Susanne Ebrecht <miracee(at)miracee(dot)de> writes:
>> ... We could provide the mixed update syntax and leave the
>> typed row value expression for the next release. Do you agree?
>
> I don't really see the point --- the patch won't provide any new
> functionality in anything like its current form, because you can
> always just write the separate expressions in the simple one to
> one way. If we do offer the row-on-the-left syntax then people
> will try to put sub-selects on the right, and won't get anything
> beyond an unhelpful "syntax error" message. So my vote would be
> to leave it alone until we have a more complete implementation.

While the patch doesn't provide any new functionality, I would still
welcome it simply because I find it a lot easier and cleaner to group
fields together when updating multiple fields at once.

Even if we would have to rip this patch back out in order to fully
support the spec, we've got a (mostly) working patch right now, and
it sounds like it would take minimal effort to finish it.

In any case, it sounds like there should be a TODO item out of this.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Susanne Ebrecht <miracee(at)miracee(dot)de>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] extension for sql update
Date: 2006-07-27 15:42:19
Message-ID: 44C8DEDB.9080408@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Susanne Ebrecht <miracee(at)miracee(dot)de> writes:
>> ... We could provide the mixed update syntax and leave the
>> typed row value expression for the next release. Do you agree?
>
> I don't really see the point --- the patch won't provide any new
> functionality in anything like its current form, because you can
> always just write the separate expressions in the simple one to
> one way. If we do offer the row-on-the-left syntax then people
> will try to put sub-selects on the right, and won't get anything
> beyond an unhelpful "syntax error" message. So my vote would be
> to leave it alone until we have a more complete implementation.

It has the advantage that inserts and updates look more "alike".
If your sql statements are generated by code, then that removes
the need of a special case for updates.

greetings, Florian Pflug


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Jim Nasby <jnasby(at)pervasive(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Susanne Ebrecht <miracee(at)miracee(dot)de>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] extension for sql update
Date: 2006-07-27 22:02:27
Message-ID: 200607272202.k6RM2RB09421@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Jim Nasby wrote:
> On Jul 27, 2006, at 7:30 AM, Tom Lane wrote:
> > Susanne Ebrecht <miracee(at)miracee(dot)de> writes:
> >> ... We could provide the mixed update syntax and leave the
> >> typed row value expression for the next release. Do you agree?
> >
> > I don't really see the point --- the patch won't provide any new
> > functionality in anything like its current form, because you can
> > always just write the separate expressions in the simple one to
> > one way. If we do offer the row-on-the-left syntax then people
> > will try to put sub-selects on the right, and won't get anything
> > beyond an unhelpful "syntax error" message. So my vote would be
> > to leave it alone until we have a more complete implementation.
>
> While the patch doesn't provide any new functionality, I would still
> welcome it simply because I find it a lot easier and cleaner to group
> fields together when updating multiple fields at once.
>
> Even if we would have to rip this patch back out in order to fully
> support the spec, we've got a (mostly) working patch right now, and
> it sounds like it would take minimal effort to finish it.
>
> In any case, it sounds like there should be a TODO item out of this.

We already had it on the TODO list, but I didn't realize about the
subselect issue. I added a sentence to clarify that:

o Allow UPDATE tab SET ROW (col, ...) = (...) for updating multiple
columns

new--> A subselect can also be used as the value source.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Susanne Ebrecht <miracee(at)miracee(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: extension for sql update
Date: 2006-07-28 07:30:16
Message-ID: 1154071816.4819.22.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Am Donnerstag, den 27.07.2006, 08:30 -0400 schrieb Tom Lane:
> Susanne Ebrecht <miracee(at)miracee(dot)de> writes:
> > ... We could provide the mixed update syntax and leave the
> > typed row value expression for the next release. Do you agree?
>
> I don't really see the point --- the patch won't provide any new
> functionality in anything like its current form, because you can
> always just write the separate expressions in the simple one to
> one way. If we do offer the row-on-the-left syntax then people
> will try to put sub-selects on the right, and won't get anything
> beyond an unhelpful "syntax error" message. So my vote would be
> to leave it alone until we have a more complete implementation.

Look at my intention, why I wrote this patch:
In recent years I migrated many customers applications from oracle or
informix to postgresql. Every time it was a very painful and annoying
job to grep through the code of functions and the whole software, to
find all updates and change them manually.

Far ago at university, I learned both syntax as standard syntax.
Example:
set a=1, b=2, c=3
and
set (a,b,c)=(1,2,3)

I admit, I prefered the second form, too, when I only used informix and
it seems also my customers do so.

Still now, I never found this syntax with select statement. I am not
sure if this is possible with informix or oracle.

regards

Susanne


>
> regards, tom lane


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
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


From: Rod Taylor <pg(at)rbt(dot)ca>
To: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, 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:38:30
Message-ID: 1154306310.24186.236.camel@home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Sun, 2006-07-30 at 20:20 -0400, Robert Treat wrote:
> 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

I disagree. UPDATE mytab SET (foo, bar, baz) =(SELECT ...) is the
specifications way of doing an update with a join. That is its primary
purpose.

UPDATE ... FROM is a PostgreSQL alternative to the above.
--


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-07-31 15:26:10
Message-ID: 200607311726.11191.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Am Mittwoch, 26. Juli 2006 22:58 schrieb Tom Lane:
> The reason people want this syntax is that they expect to be
> able to write, say,
>
> UPDATE mytab SET (foo, bar, baz) =
> (SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);

I don't find any derivation in the standard that would permit this. The only
thing I could find are variations on

SET (a) = x -- no parentheses
SET (a, b) = (x, y)
SET (a, b) = ROW (x, y)

where x and y are some sort of value expression. I would have expected the
sort of thing that you describe, but if you know how to derive that, I'd like
to see it.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Rod Taylor <pg(at)rbt(dot)ca>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-07-31 16:08:22
Message-ID: 1154362102.24186.394.camel@home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Mon, 2006-07-31 at 17:26 +0200, Peter Eisentraut wrote:
> Am Mittwoch, 26. Juli 2006 22:58 schrieb Tom Lane:
> > The reason people want this syntax is that they expect to be
> > able to write, say,
> >
> > UPDATE mytab SET (foo, bar, baz) =
> > (SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);
>
> I don't find any derivation in the standard that would permit this. The only
> thing I could find are variations on
>
> SET (a) = x -- no parentheses
> SET (a, b) = (x, y)
> SET (a, b) = ROW (x, y)
>
> where x and y are some sort of value expression. I would have expected the
> sort of thing that you describe, but if you know how to derive that, I'd like
> to see it.

I believe <contextually typed row value constructor element list> can be
one or more <value expressions> which includes a <row value expression>.
<row value expression> gives us the <row subquery> option.

For that matter the below portion of <contextually typed row value
constructor> gives us:
| <left paren> <contextually typed row value constructor element>
<comma>
<contextually typed row value constructor element list> <right
paren>

This breaks down into one or more comma separated <row subquery>s.

UPDATE tab SET (...) = ((SELECT foo, bar from a), (select bif,baz from
b));

--


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Rod Taylor <pg(at)rbt(dot)ca>
Cc: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-hackers(at)postgresql(dot)org, 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 16:40:21
Message-ID: 20060731164021.GI66525@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Sun, Jul 30, 2006 at 08:38:30PM -0400, Rod Taylor wrote:
> On Sun, 2006-07-30 at 20:20 -0400, Robert Treat wrote:
> > 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
>
> I disagree. UPDATE mytab SET (foo, bar, baz) =(SELECT ...) is the
> specifications way of doing an update with a join. That is its primary
> purpose.
>
> UPDATE ... FROM is a PostgreSQL alternative to the above.

An alternative that people have been using without complaint for years
(probably because a number of other databases do the same thing).

Perhaps a good compromise would be to allow UPDATE ... (SELECT) where it
would meet the current requirements for UPDATE ... FROM.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-07-31 20:36:11
Message-ID: 13473.1154378171@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Am Mittwoch, 26. Juli 2006 22:58 schrieb Tom Lane:
>> The reason people want this syntax is that they expect to be
>> able to write, say,
>> UPDATE mytab SET (foo, bar, baz) =
>> (SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);

> I don't find any derivation in the standard that would permit this.

Well, there are two ways to get there. SQL99 does not actually have the
syntax with parentheses on the left, but what it does have is SET ROW:

<set clause> ::=
<update target> <equals operator> <update source>
| <mutated set clause> <equals operator> <update source>

<update target> ::=
<object column>
| ROW
| <object column>
<left bracket or trigraph> <simple value specification> <right bracket or trigraph>

<update source> ::=
<value expression>
| <contextually typed value specification>

and you can derive (SELECT ...) from <value expression> via

<value expression> ::=
...
| <row value expression>

<row value expression> ::=
...
| <row value constructor>

<row value constructor> ::=
...
| <row subquery>

<row subquery> ::= <subquery>

<subquery> ::=
<left paren> <query expression> <right paren>

<query expression> ::=
[ <with clause> ] <query expression body>

<query expression body> ::=
<non-join query expression>

<non-join query expression> ::=
<non-join query term>

<non-join query term> ::=
<non-join query primary>

<non-join query primary> ::=
<simple table>

<simple table> ::=
<query specification>

<query specification> ::=
SELECT [ <set quantifier> ] <select list>
<table expression>

Another interesting restriction in SQL99 is

9) If an <update target> specifies ROW, then:

a) <set clause list> shall consist of exactly one <set clause>
SC.

SQL2003 seems to have dropped the ROW syntax entirely, but instead they
have

<set clause> ::= <multiple column assignment>

<multiple column assignment> ::=
<set target list> <equals operator> <assigned row>

<assigned row> ::= <contextually typed row value expression>

and from there it goes through just like before.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-04 19:17:50
Message-ID: 200608041917.k74JHoj28099@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


Are we sure we don't want the patch for a non-subquery version of SET
ROW for 8.2?

o Allow UPDATE tab SET ROW (col, ...) = (...) for updating multiple
columns

---------------------------------------------------------------------------

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Am Mittwoch, 26. Juli 2006 22:58 schrieb Tom Lane:
> >> The reason people want this syntax is that they expect to be
> >> able to write, say,
> >> UPDATE mytab SET (foo, bar, baz) =
> >> (SELECT alpha, beta, gamma FROM othertab WHERE key = mytab.key);
>
> > I don't find any derivation in the standard that would permit this.
>
> Well, there are two ways to get there. SQL99 does not actually have the
> syntax with parentheses on the left, but what it does have is SET ROW:
>
> <set clause> ::=
> <update target> <equals operator> <update source>
> | <mutated set clause> <equals operator> <update source>
>
> <update target> ::=
> <object column>
> | ROW
> | <object column>
> <left bracket or trigraph> <simple value specification> <right bracket or trigraph>
>
> <update source> ::=
> <value expression>
> | <contextually typed value specification>
>
> and you can derive (SELECT ...) from <value expression> via
>
> <value expression> ::=
> ...
> | <row value expression>
>
> <row value expression> ::=
> ...
> | <row value constructor>
>
> <row value constructor> ::=
> ...
> | <row subquery>
>
> <row subquery> ::= <subquery>
>
> <subquery> ::=
> <left paren> <query expression> <right paren>
>
> <query expression> ::=
> [ <with clause> ] <query expression body>
>
> <query expression body> ::=
> <non-join query expression>
>
> <non-join query expression> ::=
> <non-join query term>
>
> <non-join query term> ::=
> <non-join query primary>
>
> <non-join query primary> ::=
> <simple table>
>
> <simple table> ::=
> <query specification>
>
> <query specification> ::=
> SELECT [ <set quantifier> ] <select list>
> <table expression>
>
> Another interesting restriction in SQL99 is
>
> 9) If an <update target> specifies ROW, then:
>
> a) <set clause list> shall consist of exactly one <set clause>
> SC.
>
> SQL2003 seems to have dropped the ROW syntax entirely, but instead they
> have
>
> <set clause> ::= <multiple column assignment>
>
> <multiple column assignment> ::=
> <set target list> <equals operator> <assigned row>
>
> <assigned row> ::= <contextually typed row value expression>
>
> and from there it goes through just like before.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-11 11:53:21
Message-ID: 200608111353.22663.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:
> Are we sure we don't want the patch for a non-subquery version of SET
> ROW for 8.2?
>
> o Allow UPDATE tab SET ROW (col, ...) = (...) for updating
> multiple columns

It seems to be moderately useful as a notational convenience for now.

Is it too hard to rip it back out once the full row support arrives?
That seems speculation at best anyway.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-11 14:59:45
Message-ID: 200608111459.k7BExjj15144@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > Are we sure we don't want the patch for a non-subquery version of SET
> > ROW for 8.2?
> >
> > o Allow UPDATE tab SET ROW (col, ...) = (...) for updating
> > multiple columns
>
> It seems to be moderately useful as a notational convenience for now.
>
> Is it too hard to rip it back out once the full row support arrives?
> That seems speculation at best anyway.

That's what I was thinking. Glad someone else replied. ;-)

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-11 22:11:03
Message-ID: 20060811221103.GZ27928@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Aug 11, 2006 at 10:59:45AM -0400, Bruce Momjian wrote:
> Peter Eisentraut wrote:
> > Bruce Momjian wrote:
> > > Are we sure we don't want the patch for a non-subquery version of SET
> > > ROW for 8.2?
> > >
> > > o Allow UPDATE tab SET ROW (col, ...) = (...) for updating
> > > multiple columns
> >
> > It seems to be moderately useful as a notational convenience for now.
> >
> > Is it too hard to rip it back out once the full row support arrives?
> > That seems speculation at best anyway.
>
> That's what I was thinking. Glad someone else replied. ;-)

If you're looking for votes, +1. I'll gladly take a subset of the SQL
standard UPDATE table SET (...) = (...) over having nothing.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461


From: David Fetter <david(at)fetter(dot)org>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-12 20:16:57
Message-ID: 20060812201657.GB19427@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Aug 11, 2006 at 05:11:03PM -0500, Jim C. Nasby wrote:
> On Fri, Aug 11, 2006 at 10:59:45AM -0400, Bruce Momjian wrote:
> > Peter Eisentraut wrote:
> > > Bruce Momjian wrote:
> > > > Are we sure we don't want the patch for a non-subquery version of SET
> > > > ROW for 8.2?
> > > >
> > > > o Allow UPDATE tab SET ROW (col, ...) = (...) for updating
> > > > multiple columns
> > >
> > > It seems to be moderately useful as a notational convenience for
> > > now.
> > >
> > > Is it too hard to rip it back out once the full row support
> > > arrives? That seems speculation at best anyway.
> >
> > That's what I was thinking. Glad someone else replied. ;-)
>
> If you're looking for votes, +1. I'll gladly take a subset of the
> SQL standard UPDATE table SET (...) = (...) over having nothing.

+1 here, too. :)

Cheers,
D
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!


From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: David Fetter <david(at)fetter(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-13 15:51:17
Message-ID: 200608131151.18698.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Saturday 12 August 2006 16:16, David Fetter wrote:
> On Fri, Aug 11, 2006 at 05:11:03PM -0500, Jim C. Nasby wrote:
> > On Fri, Aug 11, 2006 at 10:59:45AM -0400, Bruce Momjian wrote:
> > > Peter Eisentraut wrote:
> > > > Bruce Momjian wrote:
> > > > > Are we sure we don't want the patch for a non-subquery version of
> > > > > SET ROW for 8.2?
> > > > >
> > > > > o Allow UPDATE tab SET ROW (col, ...) = (...) for updating
> > > > > multiple columns
> > > >
> > > > It seems to be moderately useful as a notational convenience for
> > > > now.
> > > >
> > > > Is it too hard to rip it back out once the full row support
> > > > arrives? That seems speculation at best anyway.
> > >
> > > That's what I was thinking. Glad someone else replied. ;-)
> >
> > If you're looking for votes, +1. I'll gladly take a subset of the
> > SQL standard UPDATE table SET (...) = (...) over having nothing.
>
> +1 here, too. :)
>

+1

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


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, David Fetter <david(at)fetter(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Susanne Ebrecht <miracee(at)miracee(dot)de>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-13 15:55:41
Message-ID: 200608131555.k7DFtfF23556@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Robert Treat wrote:
> On Saturday 12 August 2006 16:16, David Fetter wrote:
> > On Fri, Aug 11, 2006 at 05:11:03PM -0500, Jim C. Nasby wrote:
> > > On Fri, Aug 11, 2006 at 10:59:45AM -0400, Bruce Momjian wrote:
> > > > Peter Eisentraut wrote:
> > > > > Bruce Momjian wrote:
> > > > > > Are we sure we don't want the patch for a non-subquery version of
> > > > > > SET ROW for 8.2?
> > > > > >
> > > > > > o Allow UPDATE tab SET ROW (col, ...) = (...) for updating
> > > > > > multiple columns
> > > > >
> > > > > It seems to be moderately useful as a notational convenience for
> > > > > now.
> > > > >
> > > > > Is it too hard to rip it back out once the full row support
> > > > > arrives? That seems speculation at best anyway.
> > > >
> > > > That's what I was thinking. Glad someone else replied. ;-)
> > >
> > > If you're looking for votes, +1. I'll gladly take a subset of the
> > > SQL standard UPDATE table SET (...) = (...) over having nothing.
> >
> > +1 here, too. :)
> >
>
> +1

I am working now to get this into 8.2.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Susanne Ebrecht <miracee(at)miracee(dot)de>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-hackers(at)postgresql(dot)org, David Fetter <david(at)fetter(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-13 20:37:56
Message-ID: 44DF8DA4.4020108@miracee.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:
> Robert Treat wrote:
>
>> On Saturday 12 August 2006 16:16, David Fetter wrote:
>>
>>> On Fri, Aug 11, 2006 at 05:11:03PM -0500, Jim C. Nasby wrote:
>>>
>>>> On Fri, Aug 11, 2006 at 10:59:45AM -0400, Bruce Momjian wrote:
>>>>
>>>>> Peter Eisentraut wrote:
>>>>>
>>>>>> Bruce Momjian wrote:
>>>>>>
>>>>>>> Are we sure we don't want the patch for a non-subquery version of
>>>>>>> SET ROW for 8.2?
>>>>>>>
>>>>>>> o Allow UPDATE tab SET ROW (col, ...) = (...) for updating
>>>>>>> multiple columns
>>>>>>>
>>>>>> It seems to be moderately useful as a notational convenience for
>>>>>> now.
>>>>>>
>>>>>> Is it too hard to rip it back out once the full row support
>>>>>> arrives? That seems speculation at best anyway.
>>>>>>
>>>>> That's what I was thinking. Glad someone else replied. ;-)
>>>>>
>>>> If you're looking for votes, +1. I'll gladly take a subset of the
>>>> SQL standard UPDATE table SET (...) = (...) over having nothing.
>>>>
>>> +1 here, too. :)
>>>
>>>
>> +1
>>
>
> I am working now to get this into 8.2.
>
>
I am glad to read this. But what does it mean to me? Shall I change the
patch someway?

Susanne


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Susanne Ebrecht <miracee(at)miracee(dot)de>
Cc: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-hackers(at)postgresql(dot)org, David Fetter <david(at)fetter(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [PATCHES] extension for sql update
Date: 2006-08-14 02:05:59
Message-ID: 200608140205.k7E25xU24985@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Susanne Ebrecht wrote:
> >>>>> That's what I was thinking. Glad someone else replied. ;-)
> >>>>>
> >>>> If you're looking for votes, +1. I'll gladly take a subset of the
> >>>> SQL standard UPDATE table SET (...) = (...) over having nothing.
> >>>>
> >>> +1 here, too. :)
> >>>
> >>>
> >> +1
> >>
> >
> > I am working now to get this into 8.2.
> >
> >
> I am glad to read this. But what does it mean to me? Shall I change the
> patch someway?

Well, it doesn't apply to CVS HEAD. I assume it was made for 8.1.X. I
can adjust it and apply it, or you can make the changes and send in a
new version.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Susanne Ebrecht <miracee(at)miracee(dot)de>
Cc: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-patches(at)postgresql(dot)org, David Fetter <david(at)fetter(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [HACKERS] extension for sql update
Date: 2006-09-02 20:55:19
Message-ID: 200609022055.k82KtJF02060@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Susanne Ebrecht wrote:
> >>>>>> Is it too hard to rip it back out once the full row support
> >>>>>> arrives? That seems speculation at best anyway.
> >>>>>>
> >>>>> That's what I was thinking. Glad someone else replied. ;-)
> >>>>>
> >>>> If you're looking for votes, +1. I'll gladly take a subset of the
> >>>> SQL standard UPDATE table SET (...) = (...) over having nothing.
> >>>>
> >>> +1 here, too. :)
> >>>
> >>>
> >> +1
> >>
> >
> > I am working now to get this into 8.2.
> >
> >
> I am glad to read this. But what does it mean to me? Shall I change the
> patch someway?

I have merged your patch into current CVS and applied it; attached.
There was quite a bit of code drift. One drift area was the new
RETURNING clause; that was easy to fix. A more complex case is the
code no longer has values as ResTargets --- it is a simple a_expr list,
so I changed the critical assignment in gram.y from:

res_col->val = (Node *)copyObject(res_val->val);

to:

res_col->val = (Node *)copyObject(res_val);

Hope that is OK. Without that fix, it crashed. I also merged your SGML
syntax and grammer addition into the exiting UPDATE main entry.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
/bjm/diff text/x-diff 6.6 KB

From: Susanne Ebrecht <miracee(at)miracee(dot)de>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-patches(at)postgresql(dot)org, David Fetter <david(at)fetter(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [HACKERS] extension for sql update
Date: 2006-09-05 10:56:24
Message-ID: 44FD57D8.10001@miracee.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:
> Susanne Ebrecht wrote:
>
>>>>>>>> Is it too hard to rip it back out once the full row support
>>>>>>>> arrives? That seems speculation at best anyway.
>>>>>>>>
>>>>>>>>
>>>>>>> That's what I was thinking. Glad someone else replied. ;-)
>>>>>>>
>>>>>>>
>>>>>> If you're looking for votes, +1. I'll gladly take a subset of the
>>>>>> SQL standard UPDATE table SET (...) = (...) over having nothing.
>>>>>>
>>>>>>
>>>>> +1 here, too. :)
>>>>>
>>>>>
>>>>>
>>>> +1
>>>>
>>>>
>>> I am working now to get this into 8.2.
>>>
>>>
>>>
>> I am glad to read this. But what does it mean to me? Shall I change the
>> patch someway?
>>
>
> I have merged your patch into current CVS and applied it; attached.
> There was quite a bit of code drift. One drift area was the new
> RETURNING clause; that was easy to fix. A more complex case is the
> code no longer has values as ResTargets --- it is a simple a_expr list,
> so I changed the critical assignment in gram.y from:
>
> res_col->val = (Node *)copyObject(res_val->val);
>
> to:
>
> res_col->val = (Node *)copyObject(res_val);
>
> Hope that is OK. Without that fix, it crashed. I also merged your SGML
> syntax and grammer addition into the exiting UPDATE main entry.
>
Of course it is ok. Many thanks.

Susanne