Re: RESULT_OID Bug

Lists: pgsql-hackers
From: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: RESULT_OID Bug
Date: 2005-07-26 22:36:26
Message-ID: 009501c59232$766185d0$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Recent cvs versions are failing the following script;

create table oidtest(a time default now()) with oids;

CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $oidtest$
DECLARE
insert_oid_var INTEGER;
BEGIN
INSERT INTO oidtest DEFAULT VALUES;
GET DIAGNOSTICS insert_oid_var = RESULT_OID;
RETURN insert_oid_var;
END;
$oidtest$ Language plpgsql;

select oidtest();

if its working you will see an oid, if its failing you will see 1 row with blank data.

Kevin McArthur


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kevin McArthur <postgresql-list(at)stormtide(dot)ca>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-26 23:19:57
Message-ID: 20050726231957.GA85084@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jul 26, 2005 at 03:36:26PM -0700, Kevin McArthur wrote:
> Recent cvs versions are failing the following script;
>
> create table oidtest(a time default now()) with oids;
>
> CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $oidtest$
> DECLARE
> insert_oid_var INTEGER;
> BEGIN
> INSERT INTO oidtest DEFAULT VALUES;
> GET DIAGNOSTICS insert_oid_var = RESULT_OID;
> RETURN insert_oid_var;
> END;
> $oidtest$ Language plpgsql;
>
> select oidtest();
>
> if its working you will see an oid, if its failing you will see 1 row with blank data.

The function appears to work in a session until you replace it (or
drop and recreate it), after which you get NULL. If you exit the
session and reconnect then it works again. I checked 8.0.3 and it
doesn't have this problem.

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


From: "Kevin McArthur" <Kevin(at)StormTide(dot)ca>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RESULT_OID Bug
Date: 2005-07-26 23:36:59
Message-ID: 00d101c5923a$eb20f010$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I cannot repoduce your experience with this bug. No matter what I do,
reconnect session or otherwise, it never returns a proper oid on the newer
cvs vers (I suspect it may be related to the roles update)

Kevin
----- Original Message -----
From: "Michael Fuhr" <mike(at)fuhr(dot)org>
To: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Sent: Tuesday, July 26, 2005 4:19 PM
Subject: Re: [HACKERS] RESULT_OID Bug

> On Tue, Jul 26, 2005 at 03:36:26PM -0700, Kevin McArthur wrote:
>> Recent cvs versions are failing the following script;
>>
>> create table oidtest(a time default now()) with oids;
>>
>> CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $oidtest$
>> DECLARE
>> insert_oid_var INTEGER;
>> BEGIN
>> INSERT INTO oidtest DEFAULT VALUES;
>> GET DIAGNOSTICS insert_oid_var = RESULT_OID;
>> RETURN insert_oid_var;
>> END;
>> $oidtest$ Language plpgsql;
>>
>> select oidtest();
>>
>> if its working you will see an oid, if its failing you will see 1 row
>> with blank data.
>
> The function appears to work in a session until you replace it (or
> drop and recreate it), after which you get NULL. If you exit the
> session and reconnect then it works again. I checked 8.0.3 and it
> doesn't have this problem.
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>


From: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RESULT_OID Bug
Date: 2005-07-26 23:38:21
Message-ID: 00ec01c5923b$1c3cce80$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I cannot repoduce your experience with this bug. No matter what I do,
reconnect session or otherwise, it never returns a proper oid on the newer
cvs vers (I suspect it may be related to the roles update)

Kevin

----- Original Message -----
From: "Michael Fuhr" <mike(at)fuhr(dot)org>
To: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Sent: Tuesday, July 26, 2005 4:19 PM
Subject: Re: [HACKERS] RESULT_OID Bug

> On Tue, Jul 26, 2005 at 03:36:26PM -0700, Kevin McArthur wrote:
>> Recent cvs versions are failing the following script;
>>
>> create table oidtest(a time default now()) with oids;
>>
>> CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $oidtest$
>> DECLARE
>> insert_oid_var INTEGER;
>> BEGIN
>> INSERT INTO oidtest DEFAULT VALUES;
>> GET DIAGNOSTICS insert_oid_var = RESULT_OID;
>> RETURN insert_oid_var;
>> END;
>> $oidtest$ Language plpgsql;
>>
>> select oidtest();
>>
>> if its working you will see an oid, if its failing you will see 1 row
>> with blank data.
>
> The function appears to work in a session until you replace it (or
> drop and recreate it), after which you get NULL. If you exit the
> session and reconnect then it works again. I checked 8.0.3 and it
> doesn't have this problem.
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kevin McArthur <Kevin(at)StormTide(dot)ca>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-26 23:58:15
Message-ID: 20050726235815.GA85285@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jul 26, 2005 at 04:31:21PM -0700, Kevin McArthur wrote:
> I cannot repoduce your experience with this bug. No matter what I do,
> reconnect session or otherwise, it never returns a proper oid on the newer
> cvs vers (I suspect it may be related to the roles update)

Hmmm...my system is only a couple of hours old; the only code it's
missing is the recent "Minor correction: cause ALTER ROLE role ROLE
role" commit:

http://archives.postgresql.org/pgsql-committers/2005-07/msg00545.php

Here's a test case on my system, run in a fresh session in a
newly-created database named test2:

CREATE TABLE foo (a time DEFAULT now()) WITH OIDS;

CREATE FUNCTION oidtest() RETURNS integer AS $$
DECLARE
insert_oid_var INTEGER;
BEGIN
INSERT INTO foo DEFAULT VALUES;
GET DIAGNOSTICS insert_oid_var = RESULT_OID;
RETURN insert_oid_var;
END;
$$ LANGUAGE plpgsql VOLATILE;

SELECT oidtest();
oidtest
---------
16565
(1 row)

SELECT oidtest();
oidtest
---------
16566
(1 row)

CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $$
DECLARE
insert_oid_var INTEGER;
BEGIN
INSERT INTO foo DEFAULT VALUES;
GET DIAGNOSTICS insert_oid_var = RESULT_OID;
RETURN insert_oid_var;
END;
$$ LANGUAGE plpgsql VOLATILE;

SELECT oidtest();
oidtest
---------

(1 row)

\c test2
You are now connected to database "test2".

SELECT oidtest();
oidtest
---------
16568
(1 row)

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


From: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 00:12:04
Message-ID: 011201c5923f$d1e18560$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

bash-2.05b$ ./createdb test3
CREATE DATABASE
bash-2.05b$ ./createlang plpgsql test3
bash-2.05b$ ./psql test3
Welcome to psql 8.1devel, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

test3=# CREATE TABLE foo (a time DEFAULT now()) WITH OIDS;

CREATE FUNCTION oidtest() RETURNS integer AS $$
DECLARE
insert_oid_var INTEGER;
BEGIN
INSERT INTO foo DEFAULT VALUES;
GET DIAGNOSTICS insert_oCREATE TABLE
test3=#
test3=# CREATE FUNCTION oidtest() RETURNS integer AS $$
test3$# DECLARE
test3$# insert_oid_var INTEGER;
test3$# BEGIN
test3$# INSERT INTO foo DEFAULT VALUES;
test3$# GET DIAGNOSTICS insert_oid_var = RESULT_OID;
test3$# RETURN insert_oid_var;
test3$# END;
test3$# $$ LANGUAGE plpgsql VOLATILE;
CREATE FUNCTION
test3=#
test3=# SELECT oidtest();
oidtest
---------

(1 row)

----- Original Message -----
From: "Michael Fuhr" <mike(at)fuhr(dot)org>
To: "Kevin McArthur" <Kevin(at)stormtide(dot)ca>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Sent: Tuesday, July 26, 2005 4:58 PM
Subject: Re: [HACKERS] RESULT_OID Bug

> On Tue, Jul 26, 2005 at 04:31:21PM -0700, Kevin McArthur wrote:
>> I cannot repoduce your experience with this bug. No matter what I do,
>> reconnect session or otherwise, it never returns a proper oid on the
>> newer
>> cvs vers (I suspect it may be related to the roles update)
>
> Hmmm...my system is only a couple of hours old; the only code it's
> missing is the recent "Minor correction: cause ALTER ROLE role ROLE
> role" commit:
>
> http://archives.postgresql.org/pgsql-committers/2005-07/msg00545.php
>
> Here's a test case on my system, run in a fresh session in a
> newly-created database named test2:
>
> CREATE TABLE foo (a time DEFAULT now()) WITH OIDS;
>
> CREATE FUNCTION oidtest() RETURNS integer AS $$
> DECLARE
> insert_oid_var INTEGER;
> BEGIN
> INSERT INTO foo DEFAULT VALUES;
> GET DIAGNOSTICS insert_oid_var = RESULT_OID;
> RETURN insert_oid_var;
> END;
> $$ LANGUAGE plpgsql VOLATILE;
>
> SELECT oidtest();
> oidtest
> ---------
> 16565
> (1 row)
>
> SELECT oidtest();
> oidtest
> ---------
> 16566
> (1 row)
>
> CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $$
> DECLARE
> insert_oid_var INTEGER;
> BEGIN
> INSERT INTO foo DEFAULT VALUES;
> GET DIAGNOSTICS insert_oid_var = RESULT_OID;
> RETURN insert_oid_var;
> END;
> $$ LANGUAGE plpgsql VOLATILE;
>
> SELECT oidtest();
> oidtest
> ---------
>
> (1 row)
>
> \c test2
> You are now connected to database "test2".
>
> SELECT oidtest();
> oidtest
> ---------
> 16568
> (1 row)
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kevin McArthur <postgresql-list(at)stormtide(dot)ca>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 02:27:53
Message-ID: 20050727022753.GA85703@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jul 26, 2005 at 04:31:21PM -0700, Kevin McArthur wrote:
> I cannot repoduce your experience with this bug. No matter what I do,
> reconnect session or otherwise, it never returns a proper oid on the
> newer cvs vers (I suspect it may be related to the roles update)

I'm seeing varying results, depending on disconnects, database
restarts, and possibly whether another session has executed the
same function in another database. I suspect our systems aren't
in exactly the same state so we're seeing slightly different results.
Here's something that starts with initdb, so hopefully it'll be 100%
reproducible:

initdb data2
postmaster -D data2 -p 9999
createlang -p 9999 plpgsql postgres
psql -p 9999 postgres

CREATE TABLE foo (a time DEFAULT now()) WITH OIDS;

CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $$
DECLARE
insert_oid_var INTEGER;
BEGIN
EXECUTE 'INSERT INTO foo DEFAULT VALUES';
GET DIAGNOSTICS insert_oid_var = RESULT_OID;
RETURN insert_oid_var;
END;
$$ LANGUAGE plpgsql VOLATILE;

SELECT oidtest();
oidtest
---------
16391
(1 row)

CREATE OR REPLACE FUNCTION oidtest() RETURNS integer AS $$
DECLARE
insert_oid_var INTEGER;
BEGIN
EXECUTE 'INSERT INTO foo DEFAULT VALUES';
GET DIAGNOSTICS insert_oid_var = RESULT_OID;
RETURN insert_oid_var;
END;
$$ LANGUAGE plpgsql VOLATILE;

SELECT oidtest();
oidtest
---------

(1 row)

When did you first notice this? When was the last time you know
for sure that it was behaving correctly?

So far I've only seen the problem with PL/pgSQL's GET DIAGNOSTICS --
I haven't been able to reproduce it with PL/Tcl's spi_lastoid.

Is anybody with a deeper understanding of the code looking at this?

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
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:08:18
Message-ID: 21451.1122437298@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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 ...

regards, tom lane


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
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/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
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:56:15
Message-ID: 21868.1122440175@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Michael Fuhr <mike(at)fuhr(dot)org> writes:
> On Wed, Jul 27, 2005 at 12:08:18AM -0400, Tom Lane wrote:
>> I tried to reproduce the problem ... no joy ...

> Hmmm...not even with the example that starts from initdb?

Nope...

> Could this be platform-specific?

Seems that way. I tried it on HPUX 10.20/HPPA/gcc 2.95.3.

My guess is that the behavior is related to plpgsql's caching
of plans for functions, and as such should be driven by the
backend's history not the whole database's history. But it's
just a guess.

regards, tom lane


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 06:12:41
Message-ID: 20050727061241.GA99579@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jul 27, 2005 at 12:56:15AM -0400, Tom Lane wrote:
> Michael Fuhr <mike(at)fuhr(dot)org> writes:
> > Could this be platform-specific?
>
> Seems that way. I tried it on HPUX 10.20/HPPA/gcc 2.95.3.

No luck on FreeBSD 4.11-STABLE/i386/gcc 2.95.4. The box that does
have a problem is Solaris 9/sparc/gcc 3.4.2.

Can anybody else reproduce the problem?

> My guess is that the behavior is related to plpgsql's caching
> of plans for functions, and as such should be driven by the
> backend's history not the whole database's history. But it's
> just a guess.

Another test case that's been consistent for me:

Session 1: connect
Session 1: create table and function
Session 1: call function; returns oid

Session 2: connect
Session 2: call function; returns NULL

Session 1: exit

Session 3: connect
Session 3: call function; returns NULL

Session 2: exit

Session 3: exit

Session 4: connect
Session 4: call function; returns oid

Session 5: connect
Session 5: call function; returns NULL

Any suggestions? Would it be useful to attach gdb to one of the
backends? If so, what should I be looking for?

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


From: Neil Conway <neilc(at)samurai(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kevin McArthur <postgresql-list(at)stormtide(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 06:34:31
Message-ID: 42E72AF7.4080306@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Michael Fuhr wrote:
> Can anybody else reproduce the problem?

I couldn't repro it, on x86 / Debian unstable / gcc 3.4.4, with current
CVS sources.

-Neil


From: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
To: "Neil Conway" <neilc(at)samurai(dot)com>, "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 07:19:51
Message-ID: 004901c5927b$94ab8ab0$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The target system for my reproduction is on FreeBSD.

Though I sitll cannot get the initdb started one to work the first time
around.

I cannot reproduce the bug on my linux machine, however I cannot test the
full initdb procedure until tomorrow on freebsd.

This error has come up in the last week or so, and my suspicion remains that
its caused by something to do with roles but that could be way wrong.

The FreeBSD machines were confirmed to work as of about a week ago ( i
reinstalled for a timezone patch and I'm pretty sure it was working then )

I can note that the \set for lastoid is properly updated when I insert into
a table. Thus the problem has to be somewhere between plpgsql and that data
via the get diagnostics interface (under the assumption that the lastoid
structure is consistent for all inserts and psql having lastoid working at
all eliminates that part of the equation).

Kevin McArthur

----- Original Message -----
From: "Neil Conway" <neilc(at)samurai(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>; "Kevin McArthur"
<postgresql-list(at)stormtide(dot)ca>; <pgsql-hackers(at)postgresql(dot)org>
Sent: Tuesday, July 26, 2005 11:34 PM
Subject: Re: [HACKERS] RESULT_OID Bug

> Michael Fuhr wrote:
>> Can anybody else reproduce the problem?
>
> I couldn't repro it, on x86 / Debian unstable / gcc 3.4.4, with current
> CVS sources.
>
> -Neil
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kevin McArthur <postgresql-list(at)stormtide(dot)ca>
Cc: Neil Conway <neilc(at)samurai(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 13:16:52
Message-ID: 20050727131652.GA18755@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jul 27, 2005 at 12:19:51AM -0700, Kevin McArthur wrote:
> The target system for my reproduction is on FreeBSD.

What version of FreeBSD? What compiler and version? So far I
haven't been able to reproduce the problem on FreeBSD 4.11-STABLE/
i386/gcc 2.95.4.

> Though I sitll cannot get the initdb started one to work the first time
> around.

Odd -- that one works (or rather, fails) every time for me on Solaris 9/
sparc/gcc 3.4.2.

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


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kevin McArthur <postgresql-list(at)stormtide(dot)ca>
Cc: Neil Conway <neilc(at)samurai(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 13:36:38
Message-ID: 20050727133638.GA18851@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jul 27, 2005 at 12:19:51AM -0700, Kevin McArthur wrote:
> This error has come up in the last week or so, and my suspicion remains
> that its caused by something to do with roles but that could be way wrong.
>
> The FreeBSD machines were confirmed to work as of about a week ago ( i
> reinstalled for a timezone patch and I'm pretty sure it was working then )

Have you tried using CVS to check out and test older code? I'll
do that myself when I get a chance. If the developers can't reproduce
the problem, then at least maybe we can narrow down which commit
is responsible so they'll have something to look at.

> I can note that the \set for lastoid is properly updated when I insert into
> a table. Thus the problem has to be somewhere between plpgsql and that data
> via the get diagnostics interface (under the assumption that the lastoid
> structure is consistent for all inserts and psql having lastoid working at
> all eliminates that part of the equation).

So far the problem does seem to be specific to whatever PL/pgSQL's
is doing, and it affects ROW_COUNT as well as RESULT_OID. I haven't
been able to reproduce the problem with PL/Tcl or with C and SPI.

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


From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 18:21:07
Message-ID: slrndefk4i.bj3.andrew+nonews@trinity.supernews.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2005-07-27, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
> So far the problem does seem to be specific to whatever PL/pgSQL's
> is doing, and it affects ROW_COUNT as well as RESULT_OID. I haven't
> been able to reproduce the problem with PL/Tcl or with C and SPI.

src/pl/plpgsql/src/pl_exec.c, function exec_stmt_getdiag, uninitialized
variable "isnull".

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: andrew(at)supernews(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 18:57:57
Message-ID: 42E7D935.90105@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew - Supernews wrote:

>On 2005-07-27, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
>
>
>>So far the problem does seem to be specific to whatever PL/pgSQL's
>>is doing, and it affects ROW_COUNT as well as RESULT_OID. I haven't
>>been able to reproduce the problem with PL/Tcl or with C and SPI.
>>
>>
>
>src/pl/plpgsql/src/pl_exec.c, function exec_stmt_getdiag, uninitialized
>variable "isnull".
>
>
>

nice catch. I see the "= false" removed in about 5 places in this
change:
http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_exec.c.diff?r1=1.146;r2=1.147

Is this the only one that matters?

cheers

(another) andrew


From: "Kevin McArthur" <Kevin(at)StormTide(dot)ca>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <andrew(at)supernews(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 20:15:23
Message-ID: 003701c592e7$ec3f76d0$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

It is the only one that currently appears to _for this bug_.

Kevin
----- Original Message -----
From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <andrew(at)supernews(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Sent: Wednesday, July 27, 2005 11:57 AM
Subject: Re: [HACKERS] RESULT_OID Bug

>
>
> Andrew - Supernews wrote:
>
>>On 2005-07-27, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
>>
>>>So far the problem does seem to be specific to whatever PL/pgSQL's
>>>is doing, and it affects ROW_COUNT as well as RESULT_OID. I haven't
>>>been able to reproduce the problem with PL/Tcl or with C and SPI.
>>>
>>
>>src/pl/plpgsql/src/pl_exec.c, function exec_stmt_getdiag, uninitialized
>>variable "isnull".
>>
>>
>
> nice catch. I see the "= false" removed in about 5 places in this change:
> http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_exec.c.diff?r1=1.146;r2=1.147
>
> Is this the only one that matters?
>
> cheers
>
> (another) andrew
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


From: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
To: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <andrew(at)supernews(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 20:20:29
Message-ID: 005201c592e8$a2da4a50$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Changing just the one appears to resolve the oid bug. Should probably talk
to neilc to see why he changed it.

I will pass along a patch for this particular case to -patches shortly

Kevin McArthur
----- Original Message -----
From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <andrew(at)supernews(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Sent: Wednesday, July 27, 2005 11:57 AM
Subject: Re: [HACKERS] RESULT_OID Bug

>
>
> Andrew - Supernews wrote:
>
>>On 2005-07-27, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
>>
>>>So far the problem does seem to be specific to whatever PL/pgSQL's
>>>is doing, and it affects ROW_COUNT as well as RESULT_OID. I haven't
>>>been able to reproduce the problem with PL/Tcl or with C and SPI.
>>>
>>
>>src/pl/plpgsql/src/pl_exec.c, function exec_stmt_getdiag, uninitialized
>>variable "isnull".
>>
>>
>
> nice catch. I see the "= false" removed in about 5 places in this change:
> http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_exec.c.diff?r1=1.146;r2=1.147
>
> Is this the only one that matters?
>
> cheers
>
> (another) andrew
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kevin McArthur <postgresql-list(at)stormtide(dot)ca>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, andrew(at)supernews(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 22:35:02
Message-ID: 20050727223502.GA26777@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jul 27, 2005 at 01:20:29PM -0700, Kevin McArthur wrote:
> Changing just the one appears to resolve the oid bug. Should probably talk
> to neilc to see why he changed it.

Initializing isnull to false in exec_stmt_getdiag() appears to fix
the bug on my Solaris 9 box as well. I'd guess the variations in
behavior were due to different platforms having different garbage
on the stack.

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


From: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <andrew(at)supernews(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RESULT_OID Bug
Date: 2005-07-27 22:58:13
Message-ID: 005401c592fe$ab3d7fd0$0701a8c0@kdesktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Sounds plausible.

Can anyone comment on whether the other instances of isnull=false being
removed need to be reset to =false

Kevin McArthur
----- Original Message -----
From: "Michael Fuhr" <mike(at)fuhr(dot)org>
To: "Kevin McArthur" <postgresql-list(at)stormtide(dot)ca>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>; <andrew(at)supernews(dot)com>;
<pgsql-hackers(at)postgresql(dot)org>
Sent: Wednesday, July 27, 2005 3:35 PM
Subject: Re: [HACKERS] RESULT_OID Bug

> On Wed, Jul 27, 2005 at 01:20:29PM -0700, Kevin McArthur wrote:
>> Changing just the one appears to resolve the oid bug. Should probably
>> talk
>> to neilc to see why he changed it.
>
> Initializing isnull to false in exec_stmt_getdiag() appears to fix
> the bug on my Solaris 9 box as well. I'd guess the variations in
> behavior were due to different platforms having different garbage
> on the stack.
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>