pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Preston M. Price <preston@clearwateranalytics.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6031: Bug with plpgsql function and RETURNS TABLE
Date: Fri, 20 May 2011 16:12:09 GMT
Message-ID: <201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org> (raw)


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.



view thread (2+ messages)  latest in thread

Message-ID: <201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org>
Permalink:  ../201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: preston@clearwateranalytics.com
  Subject: Re: BUG #6031: Bug with plpgsql function and RETURNS TABLE
  In-Reply-To: <201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org>
  References: <201105201612.p4KGC9Cx027071@wwwmaster.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox