Re: BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Daniel Grace" <dgrace(at)wingsnw(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query
Date: 2011-04-19 19:29:47
Message-ID: 7850.1303241387@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Daniel Grace" <dgrace(at)wingsnw(dot)com> writes:
> Description: Rows created by WITH (INSERT ... RETURNING) are not
> visible to the rest of the query

This is not a bug but the designed behavior. See
http://developer.postgresql.org/pgdocs/postgres/queries-with.html

particularly this bit:

The sub-statements in WITH are executed concurrently with each other and
with the main query. Therefore, when using data-modifying statements in
WITH, the order in which the specified updates actually happen is
unpredictable. All the statements are executed with the same snapshot
(see Chapter 13), so they cannot "see" each others' effects on the
target tables. This alleviates the effects of the unpredictability of
the actual order of row updates, and means that RETURNING data is the
only way to communicate changes between different WITH sub-statements
and the main query.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2011-04-20 07:07:51 Re: BUG #5818: initdb lose the single quote of locale
Previous Message Dewin 2011-04-19 19:03:15 Re: BUG #5985: CLUSTER ... USING can fail with ERROR: index xxx does not belong to table yyy