Re: UPDATE using sub selects - Mailing list pgsql-hackers

From NikhilS
Subject Re: UPDATE using sub selects
Date
Msg-id d3c4af540703142352t2476efd8ybdc8c373ef672c78@mail.gmail.com
Whole thread Raw
In response to Re: UPDATE using sub selects  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: UPDATE using sub selects  (Gaetano Mendola <mendola@bigfoot.com>)
List pgsql-hackers
Hi,
 

> The question is that since this enhances the UPDATE syntax, what changes and
> where all they need to be made with respect to the documentation?

Documentation is the very least of your worries.  What exactly is your
implementation plan?  If this were a simple or narrow fix it would
have been done already.


The implementation that I have planned is pretty similar to the way "INSERT INTO ... SELECT" has been implemented.

Along with the grammar changes in gram.y, the changes are localized in the transformUpdateStmt code path. The SELECT clause ends up becoming a subquery to the update query with the target column expressions transformed properly to include the subquery expressions. Does this sound ok?

I have tried some update-subselect variations and they seem to work. For example the case in the src/test/regress/sql/update.sql, which used to fail till now, seems to work:

UPDATE update_test SET (a,b) = (select a,b FROM update_test where c = 'foo')
  WHERE a = 10;

Will try testing out some other variations too.

Regards,
Nikhils
--
EnterpriseDB               http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: UPDATE using sub selects
Next
From: Peter Eisentraut
Date:
Subject: SoC ECPG Enhancements