Skip site navigation (1) Skip section navigation (2)

BUG #6031: Bug with plpgsql function and RETURNS TABLE

From: "Preston M(dot) Price" <preston(at)clearwateranalytics(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6031: Bug with plpgsql function and RETURNS TABLE
Date: 2011-05-20 16:12:09
Message-ID: 201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      6031
Logged by:          Preston M. Price
Email address:      preston(at)clearwateranalytics(dot)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.

Responses

pgsql-bugs by date

Next:From: Alvaro HerreraDate: 2011-05-20 20:15:58
Subject: Re: BUG #6031: Bug with plpgsql function and RETURNS TABLE
Previous:From: Koichi SuzukiDate: 2011-05-20 14:06:44
Subject: Invitation to connect on LinkedIn

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group