X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 52540D1DFC0 for ; Tue, 8 Jun 2004 12:16:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14659-03 for ; Tue, 8 Jun 2004 15:16:24 +0000 (GMT) Received: from smtp806.mail.sc5.yahoo.com (smtp806.mail.sc5.yahoo.com [66.163.168.185]) by svr1.postgresql.org (Postfix) with SMTP id 90C1DD1B343 for ; Tue, 8 Jun 2004 12:16:21 -0300 (ADT) Received: from unknown (HELO bghthinkpad) (bghcm@sbcglobal.net@68.92.151.112 with login) by smtp806.mail.sc5.yahoo.com with SMTP; 8 Jun 2004 15:16:19 -0000 Message-ID: <002301c44d6b$82b1b420$6400a8c0@bghthinkpad> Reply-To: "Brian G. Huber" From: "Brian G. Huber" To: Subject: Cursor returned from procedure ignores setFetchSize() on CallableStatement Date: Tue, 8 Jun 2004 10:16:01 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0020_01C44D41.996DA810" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200406/39 X-Sequence-Number: 10241 This is a multi-part message in MIME format. ------=_NextPart_000_0020_01C44D41.996DA810 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello all - I need to return large result sets and therefore need a cursor with a small fetch size (to avoid caching the entire query at once). However, it appears that when a cursor is returned from a callable statement setFetchSize is ignored. I set up a query that crashes with outofMemoryError if entire query is cached. I am able to sucsessfully use a Statement and setFetchSize() to avoid the crash. However, when I put the code in a procedure, the outofMEmoryError throws before I even try to access the result set, indicating that the entire query is caching. This is true with or without calling setFetchSize on the ResultSet in addition to the CallableStatement. Is this a bug or am I doing something wrong? Any comments greatly appreciated. Thanks Client Code-------------------------------------------------------------------- cn.setAutoCommit(false); CallableStatement proc =3D cn.prepareCall("{ ? =3D call reffunc2('cursor1')= }"); proc.setFetchSize(100); proc.registerOutParameter(1, Types.OTHER); proc.execute(); rds =3D (ResultSet) proc.getObject(1); rds.setFetchSize(100); while (rds.next()){ ... } Function-------------------------------------------------------------------- CREATE OR REPLACE FUNCTION public.reffunc2(refcursor) RETURNS refcursor AS ' BEGIN OPEN $1 FOR SELECT ......; RETURN $1; END; ' LANGUAGE 'plpgsql' VOLATILE ------=_NextPart_000_0020_01C44D41.996DA810 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello all -

I need to return large result sets and therefore ne= ed a=20 cursor with a small
fetch size (to avoid caching the entire query at=20 once).  However, it appears
that when a cursor is returned from a= =20 callable statement setFetchSize is
ignored.

I set up a query that= =20 crashes with outofMemoryError if entire query is
cached.  I am able= to=20 sucsessfully use a Statement and setFetchSize() to
avoid the crash. = ;=20 However, when I put the code in a procedure, the
outofMEmoryError throws= =20 before I even try to access the result set,
indicating that the entire q= uery=20 is caching.  This is true with or without
calling setFetchSize on t= he=20 ResultSet in addition to the CallableStatement.

Is this a bug or am = I=20 doing something wrong?  Any comments greatly
appreciated.=20 Thanks

Client
Code-----------------------------------------------= ---------------------

cn.setAutoCommit(false);
CallableStatement= =20 proc =3D cn.prepareCall("{ ? =3D call reffunc2('cursor1')=20 }");
proc.setFetchSize(100);
proc.registerOutParameter(1,=20 Types.OTHER);
proc.execute();
rds =3D (ResultSet)=20 proc.getObject(1);
rds.setFetchSize(100);
while=20 (rds.next()){
...
}
Function--------------------------------------= ------------------------------

CREATE=20 OR REPLACE FUNCTION public.reffunc2(refcursor) RETURNS refcursor AS=20 '
BEGIN
OPEN $1 FOR SELECT ...<Large Query>...;
RETURN=20 $1;
END;
' LANGUAGE 'plpgsql' VOLATILE
------=_NextPart_000_0020_01C44D41.996DA810--