Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: aburacze(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter
Date: 2012-03-22 17:57:02
Message-ID: 10777.1332439022@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

aburacze(at)gmail(dot)com writes:
> I have just found strange behaviour of PL/pgSQL in case of using OUT
> parameters and GET DIAGNOSTICS var = ROW_COUNT (PostgreSQL 9.1.3). Here is a
> self-contained example:

Wow, that's been broken since the beginning, apparently. There's an
entirely bogus test in exec_stmt_getdiag():

if (diag_item->target <= 0)
continue;

It's not clear what the point of this is, since there is no case in
which the target variable should be invalid, but in any case the effect
is to ignore attempts to assign to any variable with dno zero --- which
will be the one first defined in the function, eg the first parameter
if any. I guess I can see how this escaped detection for a long time,
but it's broken for sure. Thanks for the report!

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Adam Buraczewski 2012-03-22 19:16:55 Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter
Previous Message Kevin Grittner 2012-03-22 17:53:01 Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter