Re: Bug in PL/pgSQL GET DIAGNOSTICS? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Bug in PL/pgSQL GET DIAGNOSTICS?
Date
Msg-id 9076.1034639477@sss.pgh.pa.us
Whole thread Raw
In response to Bug in PL/pgSQL GET DIAGNOSTICS?  ("Michael Paesold" <mpaesold@gmx.at>)
List pgsql-hackers
"Michael Paesold" <mpaesold@gmx.at> writes:
> In a PL/pgSQL function I want to insert into a table and get the OID back.
> That usually works with
> GET DIAGNOSTICS last_oid = RESULT_OID;
> right after the insert statement.

> But if the table that I insert to has a rule (or perhaps a trigger?) that
> updates another table, the RESULT_OID after the insert will be 0 (zero).

As of CVS tip, this example produces the results I believe you want:

regression=# SELECT pltestfunc(10);
NOTICE:  RESULT_OID: 282229
NOTICE:  RESULT_OID: 282230
NOTICE:  RESULT_OID: 282231
NOTICE:  RESULT_OID: 282232
NOTICE:  RESULT_OID: 282233
NOTICE:  RESULT_OID: 282234
NOTICE:  RESULT_OID: 282235
NOTICE:  RESULT_OID: 282236
NOTICE:  RESULT_OID: 282237
NOTICE:  RESULT_OID: 282238pltestfunc
------------t
(1 row)

regression=# SELECT * FROM pltest;id |  t
----+------ 1 | test 2 | test 3 | test 4 | test 5 | test 6 | test 7 | test 8 | test 9 | test10 | test
(10 rows)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: Let's get 7.3 done
Next
From: Tom Lane
Date:
Subject: Re: interesting side effect of autocommit = off