Re: [HACKERS] wCTE behaviour

2011-02-25 Thread Tom Lane
Marko Tiikkaja marko.tiikk...@cs.helsinki.fi writes: On 2011-02-25 1:36 AM, Tom Lane wrote: Why is it necessary to hack the portal logic at all? The patch seems to work for me without that. (I've fixed quite a few bugs though, so maybe what this is really doing is masking a problem

Re: [HACKERS] wCTE behaviour

2011-02-25 Thread Marko Tiikkaja
On 2011-02-25 6:12 PM, Tom Lane wrote: Marko Tiikkajamarko.tiikk...@cs.helsinki.fi writes: Without hacking it broke when PQdescribePrepared was called on a prepared query like: WITH t AS (DELETE FROM foo) SELECT 1; Not sure if that's an actual problem, but it seemed like something worht

Re: [HACKERS] wCTE behaviour

2011-02-25 Thread Tom Lane
Marko Tiikkaja marko.tiikk...@cs.helsinki.fi writes: On 2011-02-25 6:12 PM, Tom Lane wrote: The current implementation with everything in one plantree really ought to look just like a SELECT so far as the portal code is concerned. The problem was that the old code was using

Re: [HACKERS] wCTE behaviour

2011-02-24 Thread Tom Lane
Marko Tiikkaja marko.tiikk...@cs.helsinki.fi writes: I fixed an issue with the portal logic, and now we use PORTAL_ONE_RETURNING for wCTE queries, even if the main query is not a DML or does not have RETURNING. This also means that we materialize the results of the main query sometimes

Re: [HACKERS] wCTE behaviour

2011-02-24 Thread Marko Tiikkaja
On 2011-02-25 1:36 AM, Tom Lane wrote: Marko Tiikkajamarko.tiikk...@cs.helsinki.fi writes: I fixed an issue with the portal logic, and now we use PORTAL_ONE_RETURNING for wCTE queries, even if the main query is not a DML or does not have RETURNING. This also means that we materialize the

Re: [HACKERS] wCTE behaviour

2010-12-22 Thread Peter Eisentraut
On sön, 2010-11-14 at 04:45 +0200, Marko Tiikkaja wrote: .. and a wild patch appears. This is almost exactly the patch from 2010-02 without CommandCounterIncrement()s. It's still a bit rough around the edges and needs some more comments, but I'm posting it here anyway. Is this the patch

Re: [HACKERS] wCTE behaviour

2010-12-22 Thread Peter Eisentraut
On tis, 2010-12-21 at 13:20 -0800, David Fetter wrote: On Tue, Dec 21, 2010 at 11:14:31PM +0200, Peter Eisentraut wrote: On sön, 2010-11-14 at 04:45 +0200, Marko Tiikkaja wrote: On 2010-11-12 8:25 PM +0200, I wrote: I'm going to take some time off this weekend to get a patch with this

Re: [HACKERS] wCTE behaviour

2010-12-22 Thread Marko Tiikkaja
On 2010-12-22 8:24 PM, Peter Eisentraut wrote: On sön, 2010-11-14 at 04:45 +0200, Marko Tiikkaja wrote: .. and a wild patch appears. This is almost exactly the patch from 2010-02 without CommandCounterIncrement()s. It's still a bit rough around the edges and needs some more comments, but I'm

Re: [HACKERS] wCTE behaviour

2010-12-22 Thread Tom Lane
Marko Tiikkaja marko.tiikk...@cs.helsinki.fi writes: On 2010-12-22 8:24 PM, Peter Eisentraut wrote: Is this the patch of record? There are no changes to the documentation included. I've kept the documentation as a separate patch, but I haven't touched it in a very long time. I will work

Re: [HACKERS] wCTE behaviour

2010-12-21 Thread Peter Eisentraut
On sön, 2010-11-14 at 04:45 +0200, Marko Tiikkaja wrote: On 2010-11-12 8:25 PM +0200, I wrote: I'm going to take some time off this weekend to get a patch with this behaviour to the next commitfest. .. and a wild patch appears. This is almost exactly the patch from 2010-02 without

Re: [HACKERS] wCTE behaviour

2010-12-21 Thread David Fetter
On Tue, Dec 21, 2010 at 11:14:31PM +0200, Peter Eisentraut wrote: On sön, 2010-11-14 at 04:45 +0200, Marko Tiikkaja wrote: On 2010-11-12 8:25 PM +0200, I wrote: I'm going to take some time off this weekend to get a patch with this behaviour to the next commitfest. .. and a wild patch

Re: [HACKERS] wCTE behaviour

2010-12-08 Thread David Fetter
On Wed, Dec 08, 2010 at 01:23:59PM +0200, Marko Tiikkaja wrote: On 2010-12-08 10:19 AM +0200, David Fetter wrote: On Sun, Dec 05, 2010 at 01:33:39PM -0500, Greg Smith wrote: So this patch was marked Ready for Committer, but a) no committer has picked it up yet and b) Marko has made changes

Re: [HACKERS] wCTE behaviour

2010-12-08 Thread David Fetter
On Sun, Dec 05, 2010 at 01:33:39PM -0500, Greg Smith wrote: Marko Tiikkaja wrote: This is almost exactly the patch from 2010-02 without CommandCounterIncrement()s. It's still a bit rough around the edges and needs some more comments, but I'm posting it here anyway. This patch passes all

Re: [HACKERS] wCTE behaviour

2010-12-08 Thread Marko Tiikkaja
On 2010-12-08 10:19 AM +0200, David Fetter wrote: On Sun, Dec 05, 2010 at 01:33:39PM -0500, Greg Smith wrote: So this patch was marked Ready for Committer, but a) no committer has picked it up yet and b) Marko has made changes here that nobody else has tested out yet that I've seen on the last.

Re: [HACKERS] wCTE behaviour

2010-12-05 Thread Greg Smith
Marko Tiikkaja wrote: This is almost exactly the patch from 2010-02 without CommandCounterIncrement()s. It's still a bit rough around the edges and needs some more comments, but I'm posting it here anyway. This patch passes all regression tests, but feel free to try to break it, there are

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Hitoshi Harada
2010/11/14 Marko Tiikkaja marko.tiikk...@cs.helsinki.fi: On 2010-11-12 8:25 PM +0200, I wrote: I'm going to take some time off this weekend to get a patch with this behaviour to the next commitfest. .. and a wild patch appears. This is almost exactly the patch from 2010-02 without

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Marko Tiikkaja
On 2010-11-14 5:28 PM +0200, Hitoshi Harada wrote: 2010/11/14 Marko Tiikkajamarko.tiikk...@cs.helsinki.fi: .. and a wild patch appears. Could you update wiki on this feature if you think we've reached the consensus? You're probably referring to

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Marko Tiikkaja
On 2010-11-14 8:01 PM +0200, I wrote: In my opinion, all of these should have the same effect: DELETE all rows from foo. Since the example wasn't entirely clear on this one: in my opinion the DML should also only be executed once. So: WITH t AS (INSERT INTO foo VALUES (0) RETURNING *)

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Robert Haas
On Sun, Nov 14, 2010 at 1:01 PM, Marko Tiikkaja marko.tiikk...@cs.helsinki.fi wrote: In my opinion, all of these should have the same effect: DELETE all rows from foo.  Any other option means we're going to have trouble predicting how a query is going to behave. I think it's clear that's the

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Yeb Havinga
On 2010-11-14 19:35, Robert Haas wrote: On Sun, Nov 14, 2010 at 1:01 PM, Marko Tiikkaja marko.tiikk...@cs.helsinki.fi wrote: In my opinion, all of these should have the same effect: DELETE all rows from foo. Any other option means we're going to have trouble predicting how a query is going to

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Marko Tiikkaja
On 2010-11-14 8:51 PM +0200, Yeb Havinga wrote: On 2010-11-14 19:35, Robert Haas wrote: On Sun, Nov 14, 2010 at 1:01 PM, Marko Tiikkaja marko.tiikk...@cs.helsinki.fi wrote: In my opinion, all of these should have the same effect: DELETE all rows from foo. Any other option means we're going

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Robert Haas
On Sun, Nov 14, 2010 at 1:51 PM, Yeb Havinga yebhavi...@gmail.com wrote: On 2010-11-14 19:35, Robert Haas wrote: On Sun, Nov 14, 2010 at 1:01 PM, Marko Tiikkaja marko.tiikk...@cs.helsinki.fi  wrote: In my opinion, all of these should have the same effect: DELETE all rows from foo.  Any

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread David Fetter
On Sun, Nov 14, 2010 at 08:07:22PM +0200, Marko Tiikkaja wrote: On 2010-11-14 8:01 PM +0200, I wrote: In my opinion, all of these should have the same effect: DELETE all rows from foo. Since the example wasn't entirely clear on this one: in my opinion the DML should also only be executed

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Sun, Nov 14, 2010 at 1:51 PM, Yeb Havinga yebhavi...@gmail.com wrote: What if CTE's ever get input parameters? Then they'd be functions, which we already have. If you mean something like prepare foo(int) as with x as

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Yeb Havinga
On 2010-11-14 21:06, Marko Tiikkaja wrote: On 2010-11-14 8:51 PM +0200, Yeb Havinga wrote: On 2010-11-14 19:35, Robert Haas wrote: On Sun, Nov 14, 2010 at 1:01 PM, Marko Tiikkaja marko.tiikk...@cs.helsinki.fi wrote: In my opinion, all of these should have the same effect: DELETE all rows

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread Peter Eisentraut
On tor, 2010-11-11 at 19:35 +0200, Marko Tiikkaja wrote: I apologize, I had misunderstood what you are suggesting. But now that I do, it seems to be an even worse idea to go your way. Based on my research, I'm almost certain that the SQL standard says that the execution order is

Re: [HACKERS] wCTE behaviour

2010-11-14 Thread David Fetter
On Sun, Nov 14, 2010 at 11:02:08PM +0100, Yeb Havinga wrote: On 2010-11-14 21:06, Marko Tiikkaja wrote: On 2010-11-14 8:51 PM +0200, Yeb Havinga wrote: On 2010-11-14 19:35, Robert Haas wrote: On Sun, Nov 14, 2010 at 1:01 PM, Marko Tiikkaja marko.tiikk...@cs.helsinki.fi wrote: In my

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Yeb Havinga
On 2010-11-12 16:51, David Fetter wrote: On Fri, Nov 12, 2010 at 10:25:51AM -0500, Tom Lane wrote: Yeah, that's another interesting question: should we somehow force unreferenced CTEs to be evaluated anyhow? Yes. After a night's sleep I'm still thinking no. Arguments: 1) the name Common

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread David Fetter
On Sat, Nov 13, 2010 at 02:28:35PM +0100, Yeb Havinga wrote: On 2010-11-12 16:51, David Fetter wrote: On Fri, Nov 12, 2010 at 10:25:51AM -0500, Tom Lane wrote: Yeah, that's another interesting question: should we somehow force unreferenced CTEs to be evaluated anyhow? Yes. After a night's

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Yeb Havinga
On 2010-11-13 14:41, David Fetter wrote: On Sat, Nov 13, 2010 at 02:28:35PM +0100, Yeb Havinga wrote: 1) the name Common Table Expression suggests that t must be regarded as an expression, hence syntactically / proof theoretic and not as a table, set of rows / model theoretic. I.e. it is not a

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Marko Tiikkaja
On 13 Nov 2010, at 15:41, David Fetter da...@fetter.org wrote: On Sat, Nov 13, 2010 at 02:28:35PM +0100, Yeb Havinga wrote: On 2010-11-12 16:51, David Fetter wrote: On Fri, Nov 12, 2010 at 10:25:51AM -0500, Tom Lane wrote: Yeah, that's another interesting question: should we somehow force

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Tom Lane
Marko Tiikkaja marko.tiikk...@cs.helsinki.fi writes: On 13 Nov 2010, at 15:41, David Fetter da...@fetter.org wrote: Similarly, if a normal CTE called a data-changing function but was nevertheless not referred to, it would still run. Actually, it wouldn't. Indeed, and that was considered a

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Marko Tiikkaja
On 2010-11-13 5:08 PM +0200, Tom Lane wrote: Marko Tiikkajamarko.tiikk...@cs.helsinki.fi writes: On 13 Nov 2010, at 15:41, David Fetterda...@fetter.org wrote: Similarly, if a normal CTE called a data-changing function but was nevertheless not referred to, it would still run. Actually, it

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Clark C. Evans
On Sat, 13 Nov 2010 17:23 +0200, Marko Tiikkaja wrote: So these queries would behave differently? WITH t AS (DELETE FROM foo RETURNING *) SELECT 1 WHERE false; WITH t AS (DELETE FROM foo RETURNING *) SELECT 1 FROM t LIMIT 0; I'm still trying to wrap my head around this new mechanism.

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Marko Tiikkaja
On 2010-11-13 5:36 PM +0200, Clark C. Evans wrote: On Sat, 13 Nov 2010 17:23 +0200, Marko Tiikkaja wrote: So these queries would behave differently? WITH t AS (DELETE FROM foo RETURNING *) SELECT 1 WHERE false; WITH t AS (DELETE FROM foo RETURNING *) SELECT 1 FROM t LIMIT 0; I'm still

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread David Fetter
On Sat, Nov 13, 2010 at 05:23:34PM +0200, Marko Tiikkaja wrote: On 2010-11-13 5:08 PM +0200, Tom Lane wrote: Marko Tiikkajamarko.tiikk...@cs.helsinki.fi writes: On 13 Nov 2010, at 15:41, David Fetterda...@fetter.org wrote: Similarly, if a normal CTE called a data-changing function but was

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread David Fetter
On Sat, Nov 13, 2010 at 03:23:42PM +0100, Yeb Havinga wrote: On 2010-11-13 14:41, David Fetter wrote: On Sat, Nov 13, 2010 at 02:28:35PM +0100, Yeb Havinga wrote: 1) the name Common Table Expression suggests that t must be regarded as an expression, hence syntactically / proof theoretic and

Re: [HACKERS] wCTE behaviour

2010-11-13 Thread Dimitri Fontaine
Alvaro Herrera alvhe...@commandprompt.com writes: It's not that straighforward though, in that the producer could stop a bit ahead of what the consumer reads, due to there being a buffer in the middle. Witness this simple example Yeah, another example where the analogy fails for us. --

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Yeb Havinga
On 2010-11-11 17:50, Marko Tiikkaja wrote: Just to be clear, the main point is whether they see the data modifications or not. The simplest case to point out this behaviour is: WITH t AS (DELETE FROM foo) SELECT * FROM foo; And the big question is: what state of foo should the SELECT

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Tom Lane
Yeb Havinga yebhavi...@gmail.com writes: On 2010-11-11 17:50, Marko Tiikkaja wrote: Just to be clear, the main point is whether they see the data modifications or not. The simplest case to point out this behaviour is: WITH t AS (DELETE FROM foo) SELECT * FROM foo; And the big question

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Robert Haas
On Fri, Nov 12, 2010 at 10:25 AM, Tom Lane t...@sss.pgh.pa.us wrote: Yeb Havinga yebhavi...@gmail.com writes: On 2010-11-11 17:50, Marko Tiikkaja wrote: Just to be clear, the main point is whether they see the data modifications or not.  The simplest case to point out this behaviour is: WITH

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread David Fetter
On Fri, Nov 12, 2010 at 10:25:51AM -0500, Tom Lane wrote: Yeb Havinga yebhavi...@gmail.com writes: On 2010-11-11 17:50, Marko Tiikkaja wrote: Just to be clear, the main point is whether they see the data modifications or not. The simplest case to point out this behaviour is: WITH t

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread David Fetter
On Fri, Nov 12, 2010 at 10:50:52AM -0500, Robert Haas wrote: On Fri, Nov 12, 2010 at 10:25 AM, Tom Lane t...@sss.pgh.pa.us wrote: Yeb Havinga yebhavi...@gmail.com writes: On 2010-11-11 17:50, Marko Tiikkaja wrote: Just to be clear, the main point is whether they see the data modifications

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Hitoshi Harada
2010/11/13 Robert Haas robertmh...@gmail.com: On Fri, Nov 12, 2010 at 10:25 AM, Tom Lane t...@sss.pgh.pa.us wrote: Yeb Havinga yebhavi...@gmail.com writes: On 2010-11-11 17:50, Marko Tiikkaja wrote: Just to be clear, the main point is whether they see the data modifications or not.  The

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Marko Tiikkaja
Hi all, It appears that we have a consensus on the behaviour. I'm going to take some time off this weekend to get a patch with this behaviour to the next commitfest. Regards, Marko Tiikkaja -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread David Fetter
On Sat, Nov 13, 2010 at 01:50:46AM +0900, Hitoshi Harada wrote: 2010/11/13 Robert Haas robertmh...@gmail.com: On Fri, Nov 12, 2010 at 10:25 AM, Tom Lane t...@sss.pgh.pa.us wrote: Yeb Havinga yebhavi...@gmail.com writes: On 2010-11-11 17:50, Marko Tiikkaja wrote: Just to be clear, the main

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: WITH t AS (DELETE FROM foo RETURNING *) SELECT * FROM t LIMIT 1; How many rows does this delete? I think we concluded that we should force the DELETE to be run to conclusion even if the outer query didn't read it all The counter-example that

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Tom Lane
Dimitri Fontaine dimi...@2ndquadrant.fr writes: Tom Lane t...@sss.pgh.pa.us writes: WITH t AS (DELETE FROM foo RETURNING *) SELECT * FROM t LIMIT 1; How many rows does this delete? I think we concluded that we should force the DELETE to be run to conclusion even if the outer query didn't

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: I can see that there's a fair argument for that position in cases like the above, but the trouble is that there are also cases where it's very hard for the user to predict how many rows will be read. As examples, mergejoins may stop short of reading all of

Re: [HACKERS] wCTE behaviour

2010-11-12 Thread Alvaro Herrera
Excerpts from Dimitri Fontaine's message of vie nov 12 17:13:59 -0300 2010: Tom Lane t...@sss.pgh.pa.us writes: WITH t AS (DELETE FROM foo RETURNING *) SELECT * FROM t LIMIT 1; How many rows does this delete? I think we concluded that we should force the DELETE to be run to

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread David Fetter
On Thu, Nov 11, 2010 at 04:15:34AM +0200, Marko Tiikkaja wrote: Hi all, The discussion around wCTE during the last week or so has brought to my attention that we don't actually have a consensus on how exactly wCTEs should behave. The question seems to be whether or not a statement should

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Marko Tiikkaja
On 2010-11-11 6:41 PM +0200, David Fetter wrote: On Thu, Nov 11, 2010 at 04:15:34AM +0200, Marko Tiikkaja wrote: The discussion around wCTE during the last week or so has brought to my attention that we don't actually have a consensus on how exactly wCTEs should behave. The question seems to

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Thom Brown
On 11 November 2010 16:50, Marko Tiikkaja marko.tiikk...@cs.helsinki.fiwrote: On 2010-11-11 6:41 PM +0200, David Fetter wrote: On Thu, Nov 11, 2010 at 04:15:34AM +0200, Marko Tiikkaja wrote: The discussion around wCTE during the last week or so has brought to my attention that we don't

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Tom Lane
Marko Tiikkaja marko.tiikk...@cs.helsinki.fi writes: On 2010-11-11 6:41 PM +0200, David Fetter wrote: On Thu, Nov 11, 2010 at 04:15:34AM +0200, Marko Tiikkaja wrote: The discussion around wCTE during the last week or so has brought to my attention that we don't actually have a consensus on how

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread David E. Wheeler
On Nov 11, 2010, at 9:13 AM, Tom Lane wrote: If we establish a precedent that WITHs can be thought of as executing before the main command, we will eventually have to de-optimize existing WITH behavior. Or else make up reasons why the inconsistency is okay in some cases and not others, but

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: I can see that, but if one can't see the result of the write, or can't determine whether or not it will be visible in advance, what's the point of writeable CTEs? The writeable CTE returns a RETURNING set, which you can and should use in the

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Tom Lane
Thom Brown t...@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

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Marko Tiikkaja
On 11 Nov 2010, at 19:13, Tom Lane t...@sss.pgh.pa.us wrote: Marko Tiikkaja marko.tiikk...@cs.helsinki.fi writes: On 2010-11-11 6:41 PM +0200, David Fetter wrote: On Thu, Nov 11, 2010 at 04:15:34AM +0200, Marko Tiikkaja wrote: The discussion around wCTE during the last week or so has brought

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Merlin Moncure
On Thu, Nov 11, 2010 at 12:13 PM, Tom Lane t...@sss.pgh.pa.us wrote: then the conclusion is foregone.  To my mind, they should be thought of as running in parallel, or at least in an indeterminate order, just exactly the same way that different data modifications made in a single

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread David E. Wheeler
On Nov 11, 2010, at 9:29 AM, Tom Lane wrote: I can see that, but if one can't see the result of the write, or can't determine whether or not it will be visible in advance, what's the point of writeable CTEs? The writeable CTE returns a RETURNING set, which you can and should use in the

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: On Nov 11, 2010, at 9:29 AM, Tom Lane wrote: The writeable CTE returns a RETURNING set, which you can and should use in the outer query. The thing that is being argued about here is what you see if you look directly at the target table rather than

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread David Fetter
On Thu, Nov 11, 2010 at 12:36:38PM -0500, Merlin Moncure wrote: On Thu, Nov 11, 2010 at 12:13 PM, Tom Lane t...@sss.pgh.pa.us wrote: then the conclusion is foregone.  To my mind, they should be thought of as running in parallel, or at least in an indeterminate order, just exactly the same

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread David Fetter
On Thu, Nov 11, 2010 at 12:34:55PM -0500, Tom Lane wrote: Thom Brown t...@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?

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Tom Lane
David Fetter da...@fetter.org writes: On Thu, Nov 11, 2010 at 12:36:38PM -0500, Merlin Moncure wrote: On Thu, Nov 11, 2010 at 12:13 PM, Tom Lane t...@sss.pgh.pa.us wrote: then the conclusion is foregone.  To my mind, they should be thought of as running in parallel, or at least in an

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Merlin Moncure
On Thu, Nov 11, 2010 at 1:53 PM, David Fetter da...@fetter.org wrote: On Thu, Nov 11, 2010 at 12:36:38PM -0500, Merlin Moncure wrote: On Thu, Nov 11, 2010 at 12:13 PM, Tom Lane t...@sss.pgh.pa.us wrote: then the conclusion is foregone.  To my mind, they should be thought of as running in

Re: [HACKERS] wCTE behaviour

2010-11-11 Thread Tom Lane
David Fetter da...@fetter.org writes: On Thu, Nov 11, 2010 at 12:34:55PM -0500, Tom Lane wrote: 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.

[HACKERS] wCTE behaviour

2010-11-10 Thread Marko Tiikkaja
Hi all, The discussion around wCTE during the last week or so has brought to my attention that we don't actually have a consensus on how exactly wCTEs should behave. The question seems to be whether or not a statement should see the modifications of statements ran before it. While I think