Re: request for sql3 compliance for the update command - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: request for sql3 compliance for the update command
Date
Msg-id 200303191436.h2JEaoJ21825@candle.pha.pa.us
Whole thread Raw
In response to Re: request for sql3 compliance for the update command  (Hannu Krosing <hannu@tm.ee>)
Responses Re: request for sql3 compliance for the update command  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I wasn't sure it made logical sense to allow correlated subqueries in
FROM because the FROM is processed before the WHERE.

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

Hannu Krosing wrote:
> Bruce Momjian kirjutas E, 17.03.2003 kell 20:49:
> > With no one replying on how to do correlated subqueries in FROM for
> > UPDATE,
> 
> Correlated subqueries not working in FROM cluse of UPDATE is IMHO a bug,
> so the way to do correlated subqueries in FROM for UPDATE would be to
> fix this bug ;)
> 
> All common sense tells me that if I can update set col1=col2 and *not*
> get the value from the first col2 to all col1's then the same should be
> true for this
> 
> hannu=# creatre table updtarget(
> hannu(# id int, val text);
> ERROR:  parser: parse error at or near "creatre" at character 1
> hannu=# create table updtarget(id int, val text);
> CREATE TABLE
> hannu=# create table updsource(id int, val text);
> CREATE TABLE
> hannu=# insert into updtarget(id) values (1);
> INSERT 16995 1
> hannu=# insert into updtarget(id) values (2);
> INSERT 16996 1
> hannu=# insert into updsource(id,val) values (1,'one');
> INSERT 16997 1
> hannu=# insert into updsource(id,val) values (2,'two');
> INSERT 16998 1
> hannu=# update updtarget set val = src.val
> hannu-# from (select s.val from updsource s
> hannu-#        where s.id=updtarget.id) as src
> hannu-# ;
> NOTICE:  Adding missing FROM-clause entry in subquery for table
> "updtarget"
> UPDATE 2
> hannu=# select * from updtarget;
>  id | val
> ----+-----
>   1 | one
>   2 | one
> (2 rows)
> 
> there should be no need to add "missing FROM-clause entry"  and the
> result *should* be:
> 
> hannu=# select * from updtarget;
>  id | val
> ----+-----
>   1 | one
>   2 | two
> (2 rows)
> 
> --------------------
> Hannu
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
> 

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Win32 native port
Next
From: Tom Lane
Date:
Subject: Re: request for sql3 compliance for the update command