plpgsql FOUND bug when SELECT INTO assigns a NULL value?

Started by Karl O. Pincover 19 years ago3 messagesgeneral
Jump to latest
#1Karl O. Pinc
kop@meme.com

Hi,

The docs say:

A SELECT INTO statement sets FOUND true if it returns a row,
false if no row is returned.

I'm running a plpgsql procedure from a trigger and
am doing a "SELECT INTO foo bar ..." where a row
matches the selection criteria, but the value of
that row's bar column is NULL. The next statement
is "IF NOT FOUND THEN" and the THEN clause is
being taken.

I would expect that because a row exists, even
though the value assigned is NULL, FOUND would
be TRUE. Are my expectations wrong?

(If so then the docs could use some clarification.
I'll also have to write a PERFORM to test for
the existance of the row followed by a SELECT
INTO to get a (possibly NULL) value. Is
there a better way to write such code?)

Thanks.

---------------------------------

select version();
version
-------------------------------------------------------------------------------------------------------
PostgreSQL 8.1.3 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC)
3.4.4 20050721 (Red Hat 3.4.4-2)
(1 row)

Karl <kop@meme.com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Karl O. Pinc (#1)
Re: plpgsql FOUND bug when SELECT INTO assigns a NULL value?

"Karl O. Pinc" <kop@meme.com> writes:

I would expect that because a row exists, even
though the value assigned is NULL, FOUND would
be TRUE. Are my expectations wrong?

No, but I think your code is. Please provide a test case demonstrating
this behavior.

regards, tom lane

#3Karl O. Pinc
kop@meme.com
In reply to: Tom Lane (#2)
Re: plpgsql FOUND bug when SELECT INTO assigns a NULL

On 10/19/2006 10:13:46 PM, Tom Lane wrote:

"Karl O. Pinc" <kop@meme.com> writes:

I would expect that because a row exists, even
though the value assigned is NULL, FOUND would
be TRUE. Are my expectations wrong?

No, but I think your code is. Please provide a test case
demonstrating
this behavior.

Thanks for the reply. I suspect you're right.

After lots of investigation what seems to be happening
is that I'm putting data in in the wrong order....

Karl <kop@meme.com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein