pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Grace <dgrace@wingsnw.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query
Date: Tue, 19 Apr 2011 15:29:47 -0400
Message-ID: <7850.1303241387@sss.pgh.pa.us> (raw)
In-Reply-To: <201104191854.p3JIsn6a074429@wwwmaster.postgresql.org>
References: <201104191854.p3JIsn6a074429@wwwmaster.postgresql.org>

"Daniel Grace" <dgrace@wingsnw.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



view thread (2+ messages)

Message-ID: <7850.1303241387@sss.pgh.pa.us>
Permalink:  ../7850.1303241387@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7850.1303241387@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrace@wingsnw.com
  Subject: Re: BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query
  In-Reply-To: <7850.1303241387@sss.pgh.pa.us>
  References: <201104191854.p3JIsn6a074429@wwwmaster.postgresql.org> <7850.1303241387@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox