From: David Johnston <polobo@yahoo.com>
To: pgsql-bugs@postgresql.org
Subject: Re: "with recursive" ignores side effects?
Date: Tue, 6 Aug 2013 12:21:24 -0700 (PDT)
Message-ID: <1375816884419-5766565.post@n5.nabble.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1308062030390.29999@localhost6.localdomain6>
References: <alpine.DEB.2.02.1308062030390.29999@localhost6.localdomain6>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Fabien COELHO-3 wrote
> The key issue for me is that table Foo is updated (as shown by the last
> column), but although 'two' was updated to '*' by iteration 1, the last
> iteration still sees the initial 'two' which does not exist anymore.
>
> Am I wrong somewhere? Or is this a subtle bug?
My recollection is that a single statement, including its WITH clauses,
always sees whatever database state was in effect at the beginning of the
statement's execution. Updates to the database during the statement are not
visible until the statement has completed.
Note that with the introduction of updateable CTE the use of the "RETURNING"
clause is needed to allow other portions of the same query to "see" the
changes made by the DDL statement.
Read section 7.8.2 in detail as you are basically implementing this when you
perform data update statements inside a function called using "SELECT".
I'm not sure I can explain this any better, nor am I certain the
documentation is as clear as it could be, but I am pretty certain the
behavior itself is intended.
A statement is not a procedure but a declaration of what you need to have
done. Recursion (iteration) allows you to more easily handle/walk
hierarchical data but said hierarchy remains static for the duration of the
query.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/with-recursive-ignores-side-effects-tp5766555p5766565.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: polobo@yahoo.com
Subject: Re: "with recursive" ignores side effects?
In-Reply-To: <1375816884419-5766565.post@n5.nabble.com>
References: <alpine.DEB.2.02.1308062030390.29999@localhost6.localdomain6> <1375816884419-5766565.post@n5.nabble.com>
* 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