Search Postgresql Archives

Re: Bug? Function with side effects not evaluated in CTE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Johnston <polobo@xxxxxxxxx> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux