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

From: Rowan Collins <rowan(dot)collins(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Bug? Function with side effects not evaluated in CTE
Date: 2013-10-17 00:14:10
Message-ID: 525F2BD2.4070209@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 17/10/2013 00:06, Merlin Moncure wrote:
> That being said, I do think it might be better behavior (and still
> technically correct per the documentation) if volatile query
> expressions were force-evaluated.

This sounds reasonable for a "yes or no" case like this, but wouldn't it
raise the question of /how many times/ the function should be evaluated?

What if the query looked more like this:

with tt_created as
(
select fn_new_item(foo) as item
from some_huge_table
)
select item
from tt_created
limit 10

Should the CTE be calculated in its entirety, running the function for
every row in some_huge_table? Or should it run at most 10 times?

Which is desired would depend on the situation, but there's no real way
to indicate in the syntax.

--
Rowan Collins
[IMSoP]

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2013-10-17 00:16:54 Re: pg_hba.conf broken after cluster upgrade
Previous Message John R Pierce 2013-10-17 00:03:27 Re: pg_hba.conf broken after cluster upgrade