Modified:
trunk/
trunk/CHANGES
trunk/src/com/mysql/jdbc/StatementImpl.java
trunk/src/testsuite/regression/StatementRegressionTest.java
Log:
Merged revisions 6585-6586,6593-6597,6599-6602,6605,6607-6609,6612,6614-6617,6619-6620,6623-6627,6632,6636-6638,6641,6649,6658-6659,6663,6665-6673,6676,6681-6682,6684,6686,6688,6690-6692 via svnmerge from
svn+ssh://mmatthews@stripped/connectors-svnroot/connector-j/branches/branch_5_1
.......
r6692 | mmatthews | 2007-12-05 13:06:40 -0600 (Wed, 05 Dec 2007) | 1 line
Fixed BUG#30508 - ResultSet returned by Statement.getGeneratedKeys() is not closed automatically when statement that created it is closed.
.......
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/branch_5_0:1-6636,6638-6670 /branches/branch_5_1:1-6582,6584-6678,6680-6689
+ /branches/branch_5_0:1-6636,6638-6670 /branches/branch_5_1:1-6582,6584-6678,6680-6692
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2007-12-05 19:06:40 UTC (rev 6692)
+++ trunk/CHANGES 2007-12-05 19:18:51 UTC (rev 6693)
@@ -81,6 +81,9 @@
"extension" interface), and tell the driver to use it by passing in the
class name via the "loadBalanceStrategy" configuration property.
+ - Fixed BUG#30508 - ResultSet returned by Statement.getGeneratedKeys() is not closed
+ automatically when statement that created it is closed.
+
10-09-07 - Version 5.1.5
- Released instead of 5.1.4 to pickup patch for BUG#31053
Modified: trunk/src/com/mysql/jdbc/StatementImpl.java
===================================================================
--- trunk/src/com/mysql/jdbc/StatementImpl.java 2007-12-05 19:06:40 UTC (rev 6692)
+++ trunk/src/com/mysql/jdbc/StatementImpl.java 2007-12-05 19:18:51 UTC (rev 6693)
@@ -483,7 +483,7 @@
* @exception SQLException
* if a database access error occurs
*/
- public void close() throws SQLException {
+ public synchronized void close() throws SQLException {
realClose(true, true);
}
@@ -1823,8 +1823,12 @@
}
}
- return com.mysql.jdbc.ResultSetImpl.getInstance(this.currentCatalog, fields,
+ com.mysql.jdbc.ResultSetImpl gkRs = com.mysql.jdbc.ResultSetImpl.getInstance(this.currentCatalog, fields,
new RowDataStatic(rowSet), this.connection, this, false);
+
+ this.openResults.add(gkRs);
+
+ return gkRs;
}
/**
@@ -2220,21 +2224,21 @@
}
}
- if (this.results != null) {
- if (closeOpenResults) {
- closeOpenResults = !this.holdResultsOpenOverClose;
- }
-
- if (closeOpenResults && this.connection != null
- && !this.connection.getHoldResultsOpenOverStatementClose()) {
+ if (closeOpenResults) {
+ closeOpenResults = !this.holdResultsOpenOverClose;
+ }
+
+ if (closeOpenResults) {
+ if (this.results != null) {
+
try {
this.results.close();
} catch (Exception ex) {
;
}
-
- this.closeAllOpenResults();
}
+
+ closeAllOpenResults();
}
if (this.connection != null) {
Modified: trunk/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- trunk/src/testsuite/regression/StatementRegressionTest.java 2007-12-05 19:06:40 UTC (rev 6692)
+++ trunk/src/testsuite/regression/StatementRegressionTest.java 2007-12-05 19:18:51 UTC (rev 6693)
@@ -4310,4 +4310,54 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#30508 - ResultSet returned by Statement.getGeneratedKeys()
+ * is not closed automatically when statement that created it is closed.
+ *
+ * @throws Exception
+ */
+ public void testBug30508() throws Exception {
+
+ try {
+ Statement ggkStatement = this.conn.createStatement();
+ this.rs = ggkStatement.getGeneratedKeys();
+ ggkStatement.close();
+
+ this.rs.next();
+ fail("Should've had an exception here");
+ } catch (SQLException sqlEx) {
+ assertEquals("S1000", sqlEx.getSQLState());
+ } finally {
+ closeMemberJDBCResources();
+ }
+
+ try {
+ this.pstmt = this.conn.prepareStatement("SELECT 1");
+ this.rs = this.pstmt.getGeneratedKeys();
+ this.pstmt.close();
+ this.rs.next();
+ fail("Should've had an exception here");
+ } catch (SQLException sqlEx) {
+ assertEquals("S1000", sqlEx.getSQLState());
+ } finally {
+ closeMemberJDBCResources();
+ }
+
+ if (versionMeetsMinimum(5, 0)) {
+ createProcedure("testBug30508", "() BEGIN SELECT 1; END");
+
+ try {
+ this.pstmt = this.conn.prepareCall("{CALL testBug30508()}");
+ this.rs = this.pstmt.getGeneratedKeys();
+ this.pstmt.close();
+ this.rs.next();
+ fail("Should've had an exception here");
+ } catch (SQLException sqlEx) {
+ assertEquals("S1000", sqlEx.getSQLState());
+ } finally {
+ closeMemberJDBCResources();
+ }
+ }
+ }
}
| Thread |
|---|
| • Connector/J commit: r6693 - in trunk: . src/com/mysql/jdbc src/testsuite/regression | mmatthews | 5 Dec |