plpgsql FOUND bug when SELECT INTO assigns a NULL value? - Mailing list pgsql-general

From Karl O. Pinc
Subject plpgsql FOUND bug when SELECT INTO assigns a NULL value?
Date
Msg-id 1161310963l.20924l.8l@mofo
Whole thread Raw
Responses Re: plpgsql FOUND bug when SELECT INTO assigns a NULL value?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: SQL function inlining
Next
From: Michael Fuhr
Date:
Subject: Re: PostGIS