Re: wCTE behaviour

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thom Brown <thom@linux.com>
Cc: Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi>, David Fetter <david@fetter.org>, pgsql-hackers@postgresql.org
Date: 2010-11-11T17:34:55Z
Lists: pgsql-hackers
Thom Brown <thom@linux.com> writes:
> WITH t AS (UPDATE foo SET col = true)
> SELECT * FROM foo WHERE col = false;

> ... Wouldn't this be more practical to have foo's UPDATEs applied prior to
> SELECT?  Otherwise what would the usecase be?

If that's what you want, you might as well just issue two separate
statements.  There is no use-case for this at all unless the WITH
produces some RETURNING data that the SELECT makes use of.

			regards, tom lane