Subject | Re: [Firebird-Java] Bug in Statement implementation? |
---|---|
Author | Roman Rokytskyy |
Post date | 2005-05-10T16:26:21Z |
> After we switched from JayBird 1.5.1 to 1.5.5 in certain situations weI cannot tell you what change has caused this bug, but it was also
> got the error:
>
> "The prepare statement identifies a prepare statement with an open
> cursor"
discovered during JayBird 2.0 development and is already fixed in HEAD.
> I'm quite sure that's a bug, but I was not able to find it.Yes, this is a bug, happens when you execute SELECT statement with
auto-commit switched off and you do not call ResultSet.next(), but simply
close the statement. Driver incorrectly assumes that there is no open cursor
and does not call isc_dsql_free_statement when ResultSet.close() is called.
You can use a workaround by calling the ResultSet.next() call.
Appropriate patch is committed to the Branch_1_5 CVS branch, also you will
find the patch below.
---------- patch to the JayBird 1.5.5 source tree ------------
Index: org/firebirdsql/jgds/GDS_Impl.java
===================================================================
RCS file:
/cvsroot/firebird/client-java/src/main/org/firebirdsql/jgds/Attic/GDS_Impl.java,v
retrieving revision 1.47.2.2
diff -u -r1.47.2.2 GDS_Impl.java
--- org/firebirdsql/jgds/GDS_Impl.java 10 Oct 2004 12:32:15 -0000 1.47.2.2
+++ org/firebirdsql/jgds/GDS_Impl.java 10 May 2005 16:16:39 -0000
@@ -899,6 +899,11 @@
out.writeInt(0); //out_message_number =
out_message_type
}
out.flush();
+
+ // if this is SELECT statement, it has open rs
+ if (stmt.getOutSqlda() != null)
+ stmt.notifyOpenResultSet();
+
if (debug) log.debug("sent");
int op = nextOperation(db);
if (op == op_sql_response) {
Index: org/firebirdsql/ngds/GDS_Impl.java
===================================================================
RCS file:
/cvsroot/firebird/client-java/src/main/org/firebirdsql/ngds/Attic/GDS_Impl.java,v
retrieving revision 1.26.2.5
diff -u -r1.26.2.5 GDS_Impl.java
--- org/firebirdsql/ngds/GDS_Impl.java 21 Nov 2004 00:19:19 -0000 1.26.2.5
+++ org/firebirdsql/ngds/GDS_Impl.java 10 May 2005 16:16:43 -0000
@@ -683,6 +683,9 @@
native_isc_dsql_execute2(tr_handle, stmt_handle, da_version,
in_xsqlda, out_xsqlda); /* @todo Fetch Statements */
+ if (stmt.getOutSqlda() != null)
+ stmt.notifyOpenResultSet();
+
if (out_xsqlda != null) {
//this would be an Execute procedure
stmt.ensureCapacity(1);