Re: RESULT_OID Bug

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin McArthur <postgresql-list(at)stormtide(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 04:32:49
Message-ID: 20050727043249.GA86206@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 27, 2005 at 12:08:18AM -0400, Tom Lane wrote:
> Michael Fuhr <mike(at)fuhr(dot)org> writes:
> > Is anybody with a deeper understanding of the code looking at this?
>
> I tried to reproduce the problem ... no joy ...

Hmmm...not even with the example that starts from initdb? I'm up
to date with the latest commits and I can consistently reproduce
it. I was just about to post that TRUNCATE apparently "fixes"
the problem:

CREATE TABLE foo (t timestamptz DEFAULT now()) WITH OIDS;

CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $$
DECLARE
foo_count integer;
foo_oid integer;
BEGIN
EXECUTE 'INSERT INTO foo DEFAULT VALUES';
GET DIAGNOSTICS foo_count = ROW_COUNT;
GET DIAGNOSTICS foo_oid = RESULT_OID;
RAISE INFO 'ROW_COUNT = %, RESULT_OID = %', foo_count, foo_oid;
RETURN foo_oid;
END;
$$ LANGUAGE plpgsql VOLATILE;

SELECT oidtest();
INFO: ROW_COUNT = 1, RESULT_OID = 17008
oidtest
---------
17008
(1 row)

CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $$
DECLARE
foo_count integer;
foo_oid integer;
BEGIN
EXECUTE 'INSERT INTO foo DEFAULT VALUES';
GET DIAGNOSTICS foo_count = ROW_COUNT;
GET DIAGNOSTICS foo_oid = RESULT_OID;
RAISE INFO 'ROW_COUNT = %, RESULT_OID = %', foo_count, foo_oid;
RETURN foo_oid;
END;
$$ LANGUAGE plpgsql VOLATILE;

SELECT oidtest();
INFO: ROW_COUNT = <NULL>, RESULT_OID = <NULL>
oidtest
---------

(1 row)

TRUNCATE foo;

SELECT oidtest();
INFO: ROW_COUNT = 1, RESULT_OID = 17011
oidtest
---------
17011
(1 row)

Could this be platform-specific? Right now I can only test with
Solaris 9/sparc, but if necessary I could build HEAD on FreeBSD
4.11-STABLE/i386.

Kevin, what platform are you using?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-07-27 04:41:26 Re: Duplicate object names in GRANT
Previous Message Tom Lane 2005-07-27 04:31:47 Re: psql as an execve(2) interpreter