BUG #6031: Bug with plpgsql function and RETURNS TABLE - Mailing list pgsql-bugs

From Preston M. Price
Subject BUG #6031: Bug with plpgsql function and RETURNS TABLE
Date
Msg-id 201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #6031: Bug with plpgsql function and RETURNS TABLE
List pgsql-bugs
The following bug has been logged online:

Bug reference:      6031
Logged by:          Preston M. Price
Email address:      preston@clearwateranalytics.com
PostgreSQL version: 8.4
Operating system:   Linux (Ubuntu)
Description:        Bug with plpgsql function and RETURNS TABLE
Details:

If I create a plpgsql function and use RETURNS TABLE
the returned result set is filled with null values rather than the values
from the table.

---SETUP---
create table test
(
    ID SERIAL PRIMARY KEY,
    VAL INT NOT NULL
);
INSERT INTO TEST(VAL) VALUES(1);
INSERT INTO TEST(VAL) VALUES(2);
INSERT INTO TEST(VAL) VALUES(3);
INSERT INTO TEST(VAL) VALUES(4);
INSERT INTO TEST(VAL) VALUES(5);

CREATE FUNCTION TEST_FUNC() RETURNS TABLE(val int) AS $$
BEGIN
    RETURN QUERY SELECT VAL FROM test;
END;
$$ LANGUAGE plpgsql;
---SETUP---

select * from TEST_FUNC();

This query yields 5 rows of null rather than the values from the test table.

pgsql-bugs by date:

Previous
From: Koichi Suzuki
Date:
Subject: Invitation to connect on LinkedIn
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #6031: Bug with plpgsql function and RETURNS TABLE