proposed todo: use insert/update returning anywhere a table is allowed

Started by Merlin Moncurealmost 19 years ago3 messages
#1Merlin Moncure
mmoncure@gmail.com

It would be great to be able to join to update, returning, etc. It
looks like the code was deliberately tied off as-is and I was
surprised not to see a todo for this.

the basic idea is to be able to do things like:
select * from (update foo set id = 1 returning *) q;

which currently syntax errors out on 'set' which is a bit odd.

here are tom's brief notes on it and also some context on how select
combined with insert/update might influence triggers:

http://archives.postgresql.org/pgsql-hackers/2006-10/msg00693.php

merlin

#2Jeff Davis
pgsql@j-davis.com
In reply to: Merlin Moncure (#1)
Re: proposed todo: use insert/update returning anywhere a table is allowed

On Tue, 2007-02-06 at 16:54 -0500, Merlin Moncure wrote:

It would be great to be able to join to update, returning, etc. It
looks like the code was deliberately tied off as-is and I was
surprised not to see a todo for this.

the basic idea is to be able to do things like:
select * from (update foo set id = 1 returning *) q;

which currently syntax errors out on 'set' which is a bit odd.

here are tom's brief notes on it and also some context on how select
combined with insert/update might influence triggers:

http://archives.postgresql.org/pgsql-hackers/2006-10/msg00693.php

Also a relevent thread:

http://archives.postgresql.org/pgsql-general/2006-09/msg00803.php

Regards,
Jeff Davis

#3Bruce Momjian
bruce@momjian.us
In reply to: Jeff Davis (#2)
Re: proposed todo: use insert/update returning anywhere a table is allowed

Added to TODO:

* Allow INSERT/UPDATE ... RETURNING inside a SELECT 'FROM' clause

http://archives.postgresql.org/pgsql-general/2006-09/msg00803.php
http://archives.postgresql.org/pgsql-hackers/2006-10/msg00693.php

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

Jeff Davis wrote:

On Tue, 2007-02-06 at 16:54 -0500, Merlin Moncure wrote:

It would be great to be able to join to update, returning, etc. It
looks like the code was deliberately tied off as-is and I was
surprised not to see a todo for this.

the basic idea is to be able to do things like:
select * from (update foo set id = 1 returning *) q;

which currently syntax errors out on 'set' which is a bit odd.

here are tom's brief notes on it and also some context on how select
combined with insert/update might influence triggers:

http://archives.postgresql.org/pgsql-hackers/2006-10/msg00693.php

Also a relevent thread:

http://archives.postgresql.org/pgsql-general/2006-09/msg00803.php

Regards,
Jeff Davis

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

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