Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter
Date
Msg-id 10777.1332439022@sss.pgh.pa.us
Whole thread Raw
In response to BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter  (aburacze@gmail.com)
Responses Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter
List pgsql-bugs
aburacze@gmail.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

pgsql-bugs by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter
Next
From: Adam Buraczewski
Date:
Subject: Re: BUG #6551: PL/pgSQL: GET DIAGNOSTICS not working for first OUT parameter