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

Refcursor problem

From: Dmitry Fomichev <dfomichev(at)reldata(dot)com>
To: "'pgsql-bugs(at)postgresql(dot)org'" <pgsql-bugs(at)postgresql(dot)org>
Subject: Refcursor problem
Date: 2002-01-03 01:29:03
Message-ID: 56D0E60C58BF6F4C8E5AB3EBF24599DC01D32E@ruby.reldata.com (view raw or flat)
Thread:
Lists: 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


Responses

pgsql-bugs by date

Next:From: Bruce MomjianDate: 2002-01-03 05:57:13
Subject: Re: After ~Crash Sequence not correct
Previous:From: Tom LaneDate: 2002-01-02 16:28:08
Subject: Re: Bug #548: Misleading documentation of `palloc'

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