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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Moshe Jacobson <moshe(at)neadwerx(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bug? Function with side effects not evaluated in CTE
Date: 2013-10-16 21:26:52
Message-ID: 7748.1381958812@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Moshe Jacobson <moshe(at)neadwerx(dot)com> writes:
> However, It behaves as one would expect if the first CTE is built with INSERT
> ... RETURNING.

CTEs containing INSERT/UPDATE/DELETE are guaranteed to be executed exactly
once. CTEs containing SELECTs are guaranteed to be executed at most once
(the documentation phrases that as "execution can stop early if the outer
query doesn't read all the rows" --- in this case, it read none of them,
since the outer query never had to evaluate the NOT IN).

I see no bug here.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2013-10-16 22:28:58 Re: pg_hba.conf broken after cluster upgrade
Previous Message Moshe Jacobson 2013-10-16 20:58:27 Re: Bug? Function with side effects not evaluated in CTE