Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id B00169FC02B for ; Fri, 27 Apr 2007 10:02:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 43521-01 for ; Fri, 27 Apr 2007 10:02:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from web39115.mail.mud.yahoo.com (web39115.mail.mud.yahoo.com [209.191.87.234]) by postgresql.org (Postfix) with SMTP id D4F799FBB09 for ; Fri, 27 Apr 2007 10:02:45 -0300 (ADT) Received: (qmail 98451 invoked by uid 60001); 27 Apr 2007 13:02:44 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=XujgLtYO2u6lJQmbCmo/Rd8TPc/qnkeR3dua/5tgarbiKarjC/XeifX7/YQ+bxm+5XQ64dGx1NUlPT/rrMbYYE6N2RcTvOXATd3L2MwjYjHlQYD7+0jdEBiqYNiFWsGo4I7WNDsKa5I9r+yck/Q/VCv9wkMUJptoEb0As0NKT+s=; X-YMail-OSG: TX1XkVkVM1lt40XKhElxt3DOd.LR1wrdS3Kq8zVjis1gUs7drzHopa2ikPa9lEaMbL1GB7L_xlgZiqlE_Y4BrrkJxbeKPn7EgTSBFlK8SwJvC6t07th7eCGyqQ-- Received: from [203.215.160.146] by web39115.mail.mud.yahoo.com via HTTP; Fri, 27 Apr 2007 06:02:44 PDT Date: Fri, 27 Apr 2007 06:02:44 -0700 (PDT) From: Altaf Malik Subject: Re: Refcursor bug To: Dave Cramer Cc: pgsql-jdbc@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-851974779-1177678964=:96653" Content-Transfer-Encoding: 8bit Message-ID: <490539.96653.qm@web39115.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.14 tagged_above=0 required=5 tests=AWL=-0.113, BAYES_00=-2.599, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, DNS_FROM_RFC_WHOIS=1.447, HTML_40_50=0.496, HTML_MESSAGE=0.001 X-Spam-Level: * X-Archive-Number: 200704/135 X-Sequence-Number: 16984 --0-851974779-1177678964=:96653 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Yes this worked in previous versions. As you close the cursor say '' when you fetch it, it closes the underlying cursor. And the send variable also points to the same variable, and you send a FETCH ALL..... which throws exception because cursor has already been closed. --Altaf Dave Cramer wrote: Did this work in previous versions ? I made a change recently which closes the refcursor immediately after reading it, because it was leaking on large batches Dave On 27-Apr-07, at 8:20 AM, Altaf Malik wrote: Hi, I encountered a bug with refcursors with the latest JDBC driver. I cannot get two refcursors as OUT parameter if both of them point to the same underlying refcursor. Steps to produce: 1- Create table: CREATE TABLE testref ( a int4, b varchar); 2-Create the function: CREATE OR REPLACE FUNCTION reftwo( A OUT REFCURSOR, B OUT REFCURSOR) RETURNS record AS $$ DECLARE V_REF REFCURSOR; BEGIN OPEN V_REF FOR SELECT * FROM testref; A:=V_REF; B:=V_REF; END; $$ LANGUAGE 'plpgsql' 3- Run the following code: con.setAutoCommit(false); CallableStatement stm = con.prepareCall("{call reftwo(?,?)}"); stm.registerOutParameter(1,Types.OTHER); stm.registerOutParameter(2,Types.OTHER); stm.execute(); ResultSet rs = (ResultSet) stm.getObject(1); ResultSet rs2 = (ResultSet) stm.getObject(2); con.setAutoCommit(true); When i execute this code, it reports the following problem: org.postgresql.util.PSQLException: ERROR: cursor "" does not exist Am i doing something wrong? --Altaf Malik --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check out new cars at Yahoo! Autos. --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos. --0-851974779-1177678964=:96653 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Yes this worked in previous versions.

As you close the cursor say '<unnamed portal 1>' when you fetch it, it closes the underlying cursor. And the send variable also points to the same variable, and you send a FETCH ALL..... which throws exception because cursor has already been closed.

--Altaf

Dave Cramer <pg@fastcrypt.com> wrote:
Did this work in previous versions ?

I made a change recently which closes the refcursor immediately after reading it, because it was leaking on large batches

Dave
On 27-Apr-07, at 8:20 AM, Altaf Malik wrote:

Hi,
 I encountered a bug with refcursors with the latest JDBC driver. I cannot get two refcursors as OUT parameter if both of them point to the same underlying refcursor.

Steps to produce:
1- Create table:
CREATE TABLE testref ( a  int4, b  varchar);

2-Create the function:
CREATE OR REPLACE FUNCTION reftwo(
 A OUT REFCURSOR, B OUT REFCURSOR)
RETURNS record AS $$  DECLARE
  V_REF REFCURSOR;
BEGIN
     OPEN V_REF FOR SELECT * FROM testref;
     A:=V_REF;
     B:=V_REF;
END;  $$ LANGUAGE 'plpgsql'

3- Run the following code:

        con.setAutoCommit(false);
        CallableStatement stm = con.prepareCall("{call reftwo(?,?)}");       
        stm.registerOutParameter(1,Types.OTHER);
        stm.registerOutParameter(2,Types.OTHER);      
        stm.execute();      
        ResultSet rs = (ResultSet) stm.getObject(1);
        ResultSet rs2 = (ResultSet) stm.getObject(2);      
        con.setAutoCommit(true);

When i execute this code, it reports the following problem:
org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist

Am i doing something wrong?

--Altaf Malik


Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.



Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos. --0-851974779-1177678964=:96653--