plpgsql FOUND bug when SELECT INTO assigns a NULL value?

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: plpgsql FOUND bug when SELECT INTO assigns a NULL value?
Date: 2006-10-20 02:22:43
Message-ID: 1161310963l.20924l.8l@mofo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-10-20 02:53:55 Re: PostGIS
Previous Message Tom Lane 2006-10-20 01:41:28 Re: SQL function inlining