From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Johnston <polobo(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Bug? Function with side effects not evaluated in CTE |
Date: | 2013-10-21 19:58:18 |
Message-ID: | 4222.1382385498@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David Johnston <polobo(at)yahoo(dot)com> writes:
> The two comparable queries are:
> A) WITH vf ( SELECT volatile_function(x) FROM generate_series(1,10) )
> SELECT * FROM vf LIMIT 1
> B) SELECT volatile_function(x) FROM generate_series(1,10) gs (x) LIMIT 1
> In (A) the relation "vf" - which is a 10-row table with the result of
> volatile_function as the only column - is limited to a single record and
> that whole row is output as-is (because of the "*")
> In (B) the relation "gs" - which is 10 rows having the result of
> generate_series as the only column - is limited to a single row and then the
> select-list project occurs against that single row (the volatile_function)
Just for the record, your interpretation of (B) is wrong. LIMIT acts
after select-list evaluation --- try a set-returning function in the
select list to see that this is true.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2013-10-21 20:29:55 | Re: Bug? Function with side effects not evaluated in CTE |
Previous Message | Tom Lane | 2013-10-21 19:51:28 | Re: Bug? Function with side effects not evaluated in CTE |