BUG #4516: FOUND variable does not work after RETURN QUERY - Mailing list pgsql-bugs

From Michal szymanski
Subject BUG #4516: FOUND variable does not work after RETURN QUERY
Date
Msg-id 200811061638.mA6GcCgp057944@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #4516: FOUND variable does not work after RETURN QUERY
List pgsql-bugs
The following bug has been logged online:

Bug reference:      4516
Logged by:          Michal szymanski
Email address:      szymanskim@datera.pl
PostgreSQL version: 8.3
Operating system:   Windows
Description:        FOUND variable does not work after RETURN QUERY
Details:

This short program display two rows instead one. If I  use RETURN NEXT it
works.

CREATE TABLE test_table (
    value  VARCHAR
);
INSERT INTO test_table VALUES ('a');
INSERT INTO test_table VALUES ('b');

CREATE OR REPLACE FUNCTION test()
  RETURNS SETOF test_table AS
$BODY$
DECLARE
BEGIN

    RETURN QUERY
        SELECT * FROM test_table WHERE value='a';
    IF NOT FOUND THEN
        RETURN QUERY
            SELECT * FROM test_table WHERE value='b';
    END IF;

    RETURN;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

select * from test()

pgsql-bugs by date:

Previous
From: "Alex Hunsaker"
Date:
Subject: Re: plperl & sort
Next
From: Tom Lane
Date:
Subject: Re: BUG #4516: FOUND variable does not work after RETURN QUERY