pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedRefcursor bug
6+ messages / 3 participants
[nested] [flat]
* Refcursor bug
@ 2007-04-27 12:20 Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 12:40 ` Re: Refcursor bug Dave Cramer <pg@fastcrypt.com>
2007-04-27 17:34 ` Re: Refcursor bug Kris Jurka <books@ejurka.com>
0 siblings, 2 replies; 6+ messages in thread
From: Altaf Malik @ 2007-04-27 12:20 UTC (permalink / raw)
To: pgsql-jdbc
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 outnew cars at Yahoo! Autos.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Refcursor bug
2007-04-27 12:20 Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
@ 2007-04-27 12:40 ` Dave Cramer <pg@fastcrypt.com>
2007-04-27 13:02 ` Re: Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
1 sibling, 1 reply; 6+ messages in thread
From: Dave Cramer @ 2007-04-27 12:40 UTC (permalink / raw)
To: Altaf Malik <mmalik_altaf@yahoo.com>; +Cc: pgsql-jdbc
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.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Refcursor bug
2007-04-27 12:20 Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 12:40 ` Re: Refcursor bug Dave Cramer <pg@fastcrypt.com>
@ 2007-04-27 13:02 ` Altaf Malik <mmalik_altaf@yahoo.com>
0 siblings, 0 replies; 6+ messages in thread
From: Altaf Malik @ 2007-04-27 13:02 UTC (permalink / raw)
To: Dave Cramer <pg@fastcrypt.com>; +Cc: pgsql-jdbc
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 outnew cars at Yahoo! Autos.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Refcursor bug
2007-04-27 12:20 Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
@ 2007-04-27 17:34 ` Kris Jurka <books@ejurka.com>
2007-04-27 17:56 ` Re: Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
1 sibling, 1 reply; 6+ messages in thread
From: Kris Jurka @ 2007-04-27 17:34 UTC (permalink / raw)
To: Altaf Malik <mmalik_altaf@yahoo.com>; +Cc: pgsql-jdbc
On Fri, 27 Apr 2007, 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.
>
Is this an actual problem or just something you came up with to make it
fail? I don't see the use case here because the previous driver version
would return the full ResultSet and then an empty one because everything
had been fetched from it. So that would be pretty useless.
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Refcursor bug
2007-04-27 12:20 Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 17:34 ` Re: Refcursor bug Kris Jurka <books@ejurka.com>
@ 2007-04-27 17:56 ` Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 18:50 ` Re: Refcursor bug Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 6+ messages in thread
From: Altaf Malik @ 2007-04-27 17:56 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Yes it is useless but at least we cannot prevent the user from doing it. Does it mean we should throw exception and not allow user to get even the first resultset? Because exception comes internally when processing the resultset.
--Altaf
Kris Jurka <books@ejurka.com> wrote:
On Fri, 27 Apr 2007, 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.
>
Is this an actual problem or just something you came up with to make it
fail? I don't see the use case here because the previous driver version
would return the full ResultSet and then an empty one because everything
had been fetched from it. So that would be pretty useless.
Kris Jurka
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Refcursor bug
2007-04-27 12:20 Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 17:34 ` Re: Refcursor bug Kris Jurka <books@ejurka.com>
2007-04-27 17:56 ` Re: Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
@ 2007-04-27 18:50 ` Dave Cramer <pg@fastcrypt.com>
0 siblings, 0 replies; 6+ messages in thread
From: Dave Cramer @ 2007-04-27 18:50 UTC (permalink / raw)
To: Altaf Malik <mmalik_altaf@yahoo.com>; +Cc: Kris Jurka <books@ejurka.com>; pgsql-jdbc
On 27-Apr-07, at 1:56 PM, Altaf Malik wrote:
> Yes it is useless but at least we cannot prevent the user from
> doing it. Does it mean we should throw exception and not allow user
> to get even the first resultset? Because exception comes internally
> when processing the resultset.
There's many things the user can do that don't work. Is this for some
other product ?
Dave
>
> --Altaf
>
> Kris Jurka <books@ejurka.com> wrote:
>
>
> On Fri, 27 Apr 2007, 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.
> >
>
> Is this an actual problem or just something you came up with to
> make it
> fail? I don't see the use case here because the previous driver
> version
> would return the full ResultSet and then an empty one because
> everything
> had been fetched from it. So that would be pretty useless.
>
> Kris Jurka
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>
> Ahhh...imagining that irresistible "new car" smell?
> Check out new cars at Yahoo! Autos.
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2007-04-27 18:50 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-27 12:20 Refcursor bug Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 12:40 ` Dave Cramer <pg@fastcrypt.com>
2007-04-27 13:02 ` Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 17:34 ` Kris Jurka <books@ejurka.com>
2007-04-27 17:56 ` Altaf Malik <mmalik_altaf@yahoo.com>
2007-04-27 18:50 ` Dave Cramer <pg@fastcrypt.com>
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