Refcursor problem - Mailing list pgsql-bugs

From Dmitry Fomichev
Subject Refcursor problem
Date
Msg-id 56D0E60C58BF6F4C8E5AB3EBF24599DC01D32E@ruby.reldata.com
Whole thread Raw
Responses Re: Refcursor problem
List pgsql-bugs
Hi,

I am running 7.2b3 and trying to make something like this work (new
refcursor stuff):

CREATE TABLE t (c text);

CREATE FUNCTION errtest(refcursor, text) RETURNS refcursor AS '
BEGIN
        OPEN $1 FOR SELECT c FROM t WHERE c=$2;
        RETURN $1;
END;
' LANGUAGE 'plpgsql';

INSERT INTO t VALUES ('123');

BEGIN;
SELECT errtest('rs', '123');
FETCH ALL IN rs;
COMMIT;

I am getting this error after FETCH ALL....

psql:errtest.sql:15: ERROR:  MemoryContextAlloc: invalid request size
2139062147

If I tweak the function, the size in the error message (2139062147) stays
the same.
However, if I change the function to

CREATE FUNCTION errtest(refcursor, integer) RETURNS refcursor AS '
BEGIN
        OPEN $1 FOR SELECT c FROM t WHERE c=text($2);
        RETURN $1;
END;
' LANGUAGE 'plpgsql';


BEGIN;
SELECT errtest('rs', 123);
FETCH ALL IN rs;
COMMIT;

everything works fine. Am I missing something here? Workaround?
The OS is Linux Red Hat 7.1, kernel 2.4.5, glibc 2.2.4

Thanks for your help!

Dmitry Fomichev

pgsql-bugs by date:

Previous
From: "guard"
Date:
Subject: pl/tcl for cygwin not install
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #549: select table privilege in postgres allows user to create index on the table