Re: Create into temp table as select doesn set "found"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Hink <hink(at)rac(dot)cz>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Create into temp table as select doesn set "found"
Date: 2014-12-18 15:51:34
Message-ID: 16270.1418917894@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Jan Hink <hink(at)rac(dot)cz> writes:
> In plpgsql procedure I have this commads:

> create temp table t_expert on commit drop as
> select * from v_expert e where user_account=$1;

> get diagnostics rowcount=row_count;
> raise notice 'found=%, rowcount=%', found, rowcount;

> The notice returned "found=f, rowcount=2"

> I expected "found" should be set properly to true, when rowcount>0.

The set of statements that affect FOUND is specified here:
http://www.postgresql.org/docs/9.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS
CREATE TABLE AS is not among them.

In a green field we might think that it would be a good idea if it did,
but at this point in plpgsql's evolution changing that behavior would
be more likely to break existing code than to make users happier.
In particular, there is intentionally not a promise that FOUND and
ROW_COUNT are set by the exact same collections of statements.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-12-18 16:08:18 Re: BUG #12273: CASE Expression BUG
Previous Message jaksits.tibor 2014-12-18 14:44:36 BUG #12273: CASE Expression BUG