BUG #5105: "Select Into Strict" does not throw NO_DATA_FOUND - Mailing list pgsql-bugs

From Walter Mesz
Subject BUG #5105: "Select Into Strict" does not throw NO_DATA_FOUND
Date
Msg-id 200910081442.n98EgPQF096076@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #5105: "Select Into Strict" does not throw NO_DATA_FOUND
Re: BUG #5105: "Select Into Strict" does not throw NO_DATA_FOUND
List pgsql-bugs
The following bug has been logged online:

Bug reference:      5105
Logged by:          Walter Mesz
Email address:      meszwalter@yahoo.de
PostgreSQL version: 8.4.0
Operating system:   Windows XP SP2
Description:        "Select Into Strict" does not throw NO_DATA_FOUND
Details:

Hi,

my problem is that this select into does not throw a NO_DATA_FOUND if my
select involves a max(). I did not see this behaviour documented anywhere
and could not find it in a reasonable time at google.

-------------code----------------------------------
create or replace function xyz() returns void as
$BODY$ declare
x integer;
begin
 SELECT max(tanum)
           INTO STRICT x
           FROM lo_prod_req
          WHERE tanum = '1234567';

         raise notice 'failed';

exception
 WHEN NO_DATA_FOUND
         THEN
         raise notice 'it should be as this';
end ;
 $BODY$
  LANGUAGE 'plpgsql';
-------------code----------------------------------


It does throw an Exception if I change the query into this though:

-------------code----------------------------------
SELECT tanum INTO STRICT x
           FROM lo_prod_req
          WHERE tanum = '1234567' limit 1;
-------------code----------------------------------

Although this query does not make much sense with the max() statement it
should work anyway

Thank you
Walter Mesz

pgsql-bugs by date:

Previous
From: "Geoff Tolley"
Date:
Subject: BUG #5102: Silent IN (list of strings) failure to detect syntax error when list is linewrapped
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #5102: Silent IN (list of strings) failure to detect syntax error when list is linewrapped