Re: UPDATE using sub selects

Поиск
Список
Период
Сортировка
От NikhilS
Тема Re: UPDATE using sub selects
Дата
Msg-id d3c4af540703142352t2476efd8ybdc8c373ef672c78@mail.gmail.com
обсуждение исходный текст
Ответ на Re: UPDATE using sub selects  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: UPDATE using sub selects  (Gaetano Mendola <mendola@bigfoot.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: UPDATE using sub selects
Следующее
От: Peter Eisentraut
Дата:
Сообщение: SoC ECPG Enhancements