Modified:
branches/branch_5_0/connector-j/CHANGES
branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
trunk/connector-j/CHANGES
trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java
trunk/connector-j/src/com/mysql/jdbc/Statement.java
trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Fixed BUG#25073 - rewriting batched statements leaks internal statement
instances, and causes a memory leak.
Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES 2006-12-14 01:03:35 UTC (rev 6165)
+++ branches/branch_5_0/connector-j/CHANGES 2006-12-14 18:19:27 UTC (rev 6166)
@@ -16,7 +16,8 @@
columns not referenced in them.
- Fixed BUG#24360 .setFetchSize() breaks prepared SHOW and other commands.
-
+
+
- Fixed BUG#24344 - useJDBCCompliantTimezoneShift with server-side prepared
statements gives different behavior than when using client-side prepared
statements. (this is now fixed if moving from server-side prepared statements
@@ -24,13 +25,16 @@
true", as the driver can't tell if this is a new deployment that never used
server-side prepared statements, or if it is an existing deployment that is
switching to client-side prepared statements from server-side prepared statements.
-
+
- Fixed BUG#23304 - DBMD using "show" and DBMD using information_schema do
not return results consistent with each other. (note this fix only
addresses the inconsistencies, not the issue that the driver is
treating schemas differently than some users expect. We will revisit
this behavior when there is full support for schemas in MySQL).
-
+
+ - Fixed BUG#25073 - rewriting batched statements leaks internal statement
+ instances, and causes a memory leak.
+
10-20-06 - Version 5.0.4
- Fixed BUG#21379 - column names don't match metadata in cases
@@ -265,9 +269,7 @@
- Handle YYYY-MM-DD hh:mm:ss format of timestamp in
ResultSet.getTimeFromString().
-
- - Fixed BUG#24840 - character encoding of "US-ASCII" doesn't map correctly
- for 4.1 or newer
+
10-19-06 - Version 3.1.14
- Fixed BUG#20479 - Updatable result set throws ClassCastException
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java 2006-12-14
01:03:35 UTC (rev 6165)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java 2006-12-14
18:19:27 UTC (rev 6166)
@@ -889,77 +889,89 @@
java.sql.PreparedStatement batchedStatement = null;
- if (this.retrieveGeneratedKeys) {
- batchedStatement = locallyScopedConn.prepareStatement(
- generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
- RETURN_GENERATED_KEYS);
- } else {
- batchedStatement = locallyScopedConn
- .prepareStatement(generateBatchedInsertSQL(valuesClause,
- numValuesPerBatch));
- }
-
int batchedParamIndex = 1;
int updateCountRunningTotal = 0;
int numberToExecuteAsMultiValue = 0;
int batchCounter = 0;
+
+ try {
+ if (this.retrieveGeneratedKeys) {
+ batchedStatement = locallyScopedConn.prepareStatement(
+ generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
+ RETURN_GENERATED_KEYS);
+ } else {
+ batchedStatement = locallyScopedConn
+ .prepareStatement(generateBatchedInsertSQL(valuesClause,
+ numValuesPerBatch));
+ }
- if (numBatchedArgs < numValuesPerBatch) {
- numberToExecuteAsMultiValue = numBatchedArgs;
- } else {
- numberToExecuteAsMultiValue = numBatchedArgs / numValuesPerBatch;
- }
-
- int numberArgsToExecute = numberToExecuteAsMultiValue * numValuesPerBatch;
-
- for (int i = 0; i < numberArgsToExecute; i++) {
- if (i != 0 && i % numValuesPerBatch == 0) {
- updateCountRunningTotal += batchedStatement.executeUpdate();
-
- getBatchedGeneratedKeys(batchedStatement);
- batchedStatement.clearParameters();
- batchedParamIndex = 1;
-
+ if (numBatchedArgs < numValuesPerBatch) {
+ numberToExecuteAsMultiValue = numBatchedArgs;
+ } else {
+ numberToExecuteAsMultiValue = numBatchedArgs / numValuesPerBatch;
}
-
- BatchParams paramArg = (BatchParams) this.batchedArgs
- .get(batchCounter++);
-
- batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
- batchedParamIndex, paramArg);
- }
-
- updateCountRunningTotal += batchedStatement.executeUpdate();
- getBatchedGeneratedKeys(batchedStatement);
-
- numValuesPerBatch = numBatchedArgs - batchCounter;
-
- if (numValuesPerBatch > 0) {
-
- batchedStatement = locallyScopedConn.prepareStatement(
- generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
- RETURN_GENERATED_KEYS);
- batchedParamIndex = 1;
-
- while (batchCounter < numBatchedArgs) {
-
+
+ int numberArgsToExecute = numberToExecuteAsMultiValue * numValuesPerBatch;
+
+ for (int i = 0; i < numberArgsToExecute; i++) {
+ if (i != 0 && i % numValuesPerBatch == 0) {
+ updateCountRunningTotal += batchedStatement.executeUpdate();
+
+ getBatchedGeneratedKeys(batchedStatement);
+ batchedStatement.clearParameters();
+ batchedParamIndex = 1;
+
+ }
+
BatchParams paramArg = (BatchParams) this.batchedArgs
.get(batchCounter++);
+
batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
batchedParamIndex, paramArg);
}
-
+
updateCountRunningTotal += batchedStatement.executeUpdate();
getBatchedGeneratedKeys(batchedStatement);
+
+ numValuesPerBatch = numBatchedArgs - batchCounter;
+ } finally {
+ if (batchedStatement != null) {
+ batchedStatement.close();
+ }
}
-
- int[] updateCounts = new int[this.batchedArgs.size()];
-
- for (int i = 0; i < this.batchedArgs.size(); i++) {
- updateCounts[i] = 1;
+
+ try {
+ if (numValuesPerBatch > 0) {
+
+ batchedStatement = locallyScopedConn.prepareStatement(
+ generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
+ RETURN_GENERATED_KEYS);
+ batchedParamIndex = 1;
+
+ while (batchCounter < numBatchedArgs) {
+
+ BatchParams paramArg = (BatchParams) this.batchedArgs
+ .get(batchCounter++);
+ batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
+ batchedParamIndex, paramArg);
+ }
+
+ updateCountRunningTotal += batchedStatement.executeUpdate();
+ getBatchedGeneratedKeys(batchedStatement);
+ }
+
+ int[] updateCounts = new int[this.batchedArgs.size()];
+
+ for (int i = 0; i < this.batchedArgs.size(); i++) {
+ updateCounts[i] = 1;
+ }
+
+ return updateCounts;
+ } finally {
+ if (batchedStatement != null) {
+ batchedStatement.close();
+ }
}
-
- return updateCounts;
}
protected int computeBatchSize(int numBatchedArgs) {
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java 2006-12-14 01:03:35
UTC (rev 6165)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java 2006-12-14 18:19:27
UTC (rev 6166)
@@ -948,6 +948,8 @@
locallyScopedConn.getIO().enableMultiQueries();
}
+ java.sql.Statement batchStmt = null;
+
try {
int[] updateCounts = new int[nbrCommands];
@@ -959,7 +961,10 @@
StringBuffer queryBuf = new StringBuffer();
- java.sql.Statement batchStmt = locallyScopedConn.createStatement();
+
+
+ batchStmt = locallyScopedConn.createStatement();
+
int counter = 0;
@@ -1032,8 +1037,14 @@
return (updateCounts != null) ? updateCounts : new int[0];
} finally {
- if (!multiQueriesEnabled) {
- locallyScopedConn.getIO().disableMultiQueries();
+ try {
+ if (batchStmt != null) {
+ batchStmt.close();
+ }
+ } finally {
+ if (!multiQueriesEnabled) {
+ locallyScopedConn.getIO().disableMultiQueries();
+ }
}
}
}
Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-12-14
01:03:35 UTC (rev 6165)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-12-14
18:19:27 UTC (rev 6166)
@@ -3598,4 +3598,95 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#25073 - rewriting batched statements leaks internal statement
+ * instances, and causes a memory leak.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug25073() throws Exception {
+ Properties props = new Properties();
+ props.setProperty("rewriteBatchedStatements", "true");
+ Connection multiConn = getConnectionWithProps(props);
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+ Statement multiStmt = multiConn.createStatement();
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (1)");
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (2)");
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (3)");
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (4)");
+ multiStmt.addBatch("UPDATE testBug25073 SET field1=5 WHERE field1=1");
+ multiStmt.addBatch("UPDATE testBug25073 SET field1=6 WHERE field1=2 OR field1=3");
+
+ int beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ multiStmt.executeBatch();
+
+ int afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+
+
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+ props.clear();
+ props.setProperty("rewriteBatchedStatements", "true");
+ props.setProperty("sessionVariables", "max_allowed_packet=1024");
+ multiConn = getConnectionWithProps(props);
+ multiStmt = multiConn.createStatement();
+
+ for (int i = 0; i < 1000; i++) {
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (" + i + ")");
+ }
+
+ beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ multiStmt.executeBatch();
+
+ afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+
+ props.clear();
+ props.setProperty("useServerPrepStmts", "false");
+ props.setProperty("rewriteBatchedStatements", "true");
+ multiConn = getConnectionWithProps(props);
+ PreparedStatement pStmt = multiConn.prepareStatement("INSERT INTO testBug25073(field1)
VALUES (?)",
+ Statement.RETURN_GENERATED_KEYS);
+
+ for (int i = 0; i < 1000; i++) {
+ pStmt.setInt(1, i);
+ pStmt.addBatch();
+ }
+
+ beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ pStmt.executeBatch();
+
+ afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+ props.setProperty("useServerPrepStmts", "false");
+ props.setProperty("rewriteBatchedStatements", "true");
+ props.setProperty("sessionVariables", "max_allowed_packet=1024");
+ multiConn = getConnectionWithProps(props);
+ pStmt = multiConn.prepareStatement("INSERT INTO testBug25073(field1) VALUES (?)",
+ Statement.RETURN_GENERATED_KEYS);
+
+ for (int i = 0; i < 1000; i++) {
+ pStmt.setInt(1, i);
+ pStmt.addBatch();
+ }
+
+ beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ pStmt.executeBatch();
+
+ afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+ }
}
Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES 2006-12-14 01:03:35 UTC (rev 6165)
+++ trunk/connector-j/CHANGES 2006-12-14 18:19:27 UTC (rev 6166)
@@ -27,7 +27,10 @@
addresses the inconsistencies, not the issue that the driver is
treating schemas differently than some users expect. We will revisit
this behavior when there is full support for schemas in MySQL).
-
+
+ - Fixed BUG#25073 - rewriting batched statements leaks internal statement
+ instances, and causes a memory leak.
+
10-20-06 - Version 5.0.4
- Fixed BUG#21379 - column names don't match metadata in cases
@@ -262,10 +265,7 @@
- Handle YYYY-MM-DD hh:mm:ss format of timestamp in
ResultSet.getTimeFromString().
-
- - Fixed BUG#24840 - character encoding of "US-ASCII" doesn't map correctly
- for 4.1 or newer
-
+
10-19-06 - Version 3.1.14
- Fixed BUG#20479 - Updatable result set throws ClassCastException
Modified: trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java 2006-12-14 01:03:35 UTC
(rev 6165)
+++ trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java 2006-12-14 18:19:27 UTC
(rev 6166)
@@ -892,77 +892,90 @@
java.sql.PreparedStatement batchedStatement = null;
- if (this.retrieveGeneratedKeys) {
- batchedStatement = locallyScopedConn.prepareStatement(
- generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
- RETURN_GENERATED_KEYS);
- } else {
- batchedStatement = locallyScopedConn
- .prepareStatement(generateBatchedInsertSQL(valuesClause,
- numValuesPerBatch));
- }
-
int batchedParamIndex = 1;
int updateCountRunningTotal = 0;
int numberToExecuteAsMultiValue = 0;
int batchCounter = 0;
-
- if (numBatchedArgs < numValuesPerBatch) {
- numberToExecuteAsMultiValue = numBatchedArgs;
- } else {
- numberToExecuteAsMultiValue = numBatchedArgs / numValuesPerBatch;
- }
-
- int numberArgsToExecute = numberToExecuteAsMultiValue * numValuesPerBatch;
-
- for (int i = 0; i < numberArgsToExecute; i++) {
- if (i != 0 && i % numValuesPerBatch == 0) {
- updateCountRunningTotal += batchedStatement.executeUpdate();
-
- getBatchedGeneratedKeys(batchedStatement);
- batchedStatement.clearParameters();
- batchedParamIndex = 1;
-
+
+ try {
+ if (this.retrieveGeneratedKeys) {
+ batchedStatement = locallyScopedConn.prepareStatement(
+ generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
+ RETURN_GENERATED_KEYS);
+ } else {
+ batchedStatement = locallyScopedConn
+ .prepareStatement(generateBatchedInsertSQL(valuesClause,
+ numValuesPerBatch));
}
-
- BatchParams paramArg = (BatchParams) this.batchedArgs
- .get(batchCounter++);
-
- batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
- batchedParamIndex, paramArg);
- }
-
- updateCountRunningTotal += batchedStatement.executeUpdate();
- getBatchedGeneratedKeys(batchedStatement);
-
- numValuesPerBatch = numBatchedArgs - batchCounter;
-
- if (numValuesPerBatch > 0) {
-
- batchedStatement = locallyScopedConn.prepareStatement(
- generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
- RETURN_GENERATED_KEYS);
- batchedParamIndex = 1;
-
- while (batchCounter < numBatchedArgs) {
-
+
+
+ if (numBatchedArgs < numValuesPerBatch) {
+ numberToExecuteAsMultiValue = numBatchedArgs;
+ } else {
+ numberToExecuteAsMultiValue = numBatchedArgs / numValuesPerBatch;
+ }
+
+ int numberArgsToExecute = numberToExecuteAsMultiValue * numValuesPerBatch;
+
+ for (int i = 0; i < numberArgsToExecute; i++) {
+ if (i != 0 && i % numValuesPerBatch == 0) {
+ updateCountRunningTotal += batchedStatement.executeUpdate();
+
+ getBatchedGeneratedKeys(batchedStatement);
+ batchedStatement.clearParameters();
+ batchedParamIndex = 1;
+
+ }
+
BatchParams paramArg = (BatchParams) this.batchedArgs
.get(batchCounter++);
+
batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
batchedParamIndex, paramArg);
}
-
+
updateCountRunningTotal += batchedStatement.executeUpdate();
getBatchedGeneratedKeys(batchedStatement);
+
+ numValuesPerBatch = numBatchedArgs - batchCounter;
+ } finally {
+ if (batchedStatement != null) {
+ batchedStatement.close();
+ }
}
-
- int[] updateCounts = new int[this.batchedArgs.size()];
-
- for (int i = 0; i < this.batchedArgs.size(); i++) {
- updateCounts[i] = 1;
+
+ try {
+ if (numValuesPerBatch > 0) {
+
+ batchedStatement = locallyScopedConn.prepareStatement(
+ generateBatchedInsertSQL(valuesClause, numValuesPerBatch),
+ RETURN_GENERATED_KEYS);
+ batchedParamIndex = 1;
+
+ while (batchCounter < numBatchedArgs) {
+
+ BatchParams paramArg = (BatchParams) this.batchedArgs
+ .get(batchCounter++);
+ batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
+ batchedParamIndex, paramArg);
+ }
+
+ updateCountRunningTotal += batchedStatement.executeUpdate();
+ getBatchedGeneratedKeys(batchedStatement);
+ }
+
+ int[] updateCounts = new int[this.batchedArgs.size()];
+
+ for (int i = 0; i < this.batchedArgs.size(); i++) {
+ updateCounts[i] = 1;
+ }
+
+ return updateCounts;
+ } finally {
+ if (batchedStatement != null) {
+ batchedStatement.close();
+ }
}
-
- return updateCounts;
}
protected int computeBatchSize(int numBatchedArgs) {
Modified: trunk/connector-j/src/com/mysql/jdbc/Statement.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/Statement.java 2006-12-14 01:03:35 UTC (rev 6165)
+++ trunk/connector-j/src/com/mysql/jdbc/Statement.java 2006-12-14 18:19:27 UTC (rev 6166)
@@ -947,6 +947,8 @@
locallyScopedConn.getIO().enableMultiQueries();
}
+ java.sql.Statement batchStmt = null;
+
try {
int[] updateCounts = new int[nbrCommands];
@@ -958,7 +960,7 @@
StringBuffer queryBuf = new StringBuffer();
- java.sql.Statement batchStmt = locallyScopedConn.createStatement();
+ batchStmt = locallyScopedConn.createStatement();
int counter = 0;
@@ -1031,8 +1033,14 @@
return (updateCounts != null) ? updateCounts : new int[0];
} finally {
- if (!multiQueriesEnabled) {
- locallyScopedConn.getIO().disableMultiQueries();
+ try {
+ if (batchStmt != null) {
+ batchStmt.close();
+ }
+ } finally {
+ if (!multiQueriesEnabled) {
+ locallyScopedConn.getIO().disableMultiQueries();
+ }
}
}
}
Modified: trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-12-14
01:03:35 UTC (rev 6165)
+++ trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-12-14
18:19:27 UTC (rev 6166)
@@ -3602,4 +3602,95 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#25073 - rewriting batched statements leaks internal statement
+ * instances, and causes a memory leak.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug25073() throws Exception {
+ Properties props = new Properties();
+ props.setProperty("rewriteBatchedStatements", "true");
+ Connection multiConn = getConnectionWithProps(props);
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+ Statement multiStmt = multiConn.createStatement();
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (1)");
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (2)");
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (3)");
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (4)");
+ multiStmt.addBatch("UPDATE testBug25073 SET field1=5 WHERE field1=1");
+ multiStmt.addBatch("UPDATE testBug25073 SET field1=6 WHERE field1=2 OR field1=3");
+
+ int beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ multiStmt.executeBatch();
+
+ int afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+
+
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+ props.clear();
+ props.setProperty("rewriteBatchedStatements", "true");
+ props.setProperty("sessionVariables", "max_allowed_packet=1024");
+ multiConn = getConnectionWithProps(props);
+ multiStmt = multiConn.createStatement();
+
+ for (int i = 0; i < 1000; i++) {
+ multiStmt.addBatch("INSERT INTO testBug25073(field1) VALUES (" + i + ")");
+ }
+
+ beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ multiStmt.executeBatch();
+
+ afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+
+ props.clear();
+ props.setProperty("useServerPrepStmts", "false");
+ props.setProperty("rewriteBatchedStatements", "true");
+ multiConn = getConnectionWithProps(props);
+ PreparedStatement pStmt = multiConn.prepareStatement("INSERT INTO testBug25073(field1)
VALUES (?)",
+ Statement.RETURN_GENERATED_KEYS);
+
+ for (int i = 0; i < 1000; i++) {
+ pStmt.setInt(1, i);
+ pStmt.addBatch();
+ }
+
+ beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ pStmt.executeBatch();
+
+ afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+
+ createTable("testBug25073", "(pk_field INT PRIMARY KEY NOT NULL AUTO_INCREMENT, field1
INT)");
+ props.setProperty("useServerPrepStmts", "false");
+ props.setProperty("rewriteBatchedStatements", "true");
+ props.setProperty("sessionVariables", "max_allowed_packet=1024");
+ multiConn = getConnectionWithProps(props);
+ pStmt = multiConn.prepareStatement("INSERT INTO testBug25073(field1) VALUES (?)",
+ Statement.RETURN_GENERATED_KEYS);
+
+ for (int i = 0; i < 1000; i++) {
+ pStmt.setInt(1, i);
+ pStmt.addBatch();
+ }
+
+ beforeOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ pStmt.executeBatch();
+
+ afterOpenStatementCount =
((com.mysql.jdbc.Connection)multiConn).getActiveStatementCount();
+
+ assertEquals(beforeOpenStatementCount, afterOpenStatementCount);
+ }
}
| Thread |
|---|
| • Connector/J commit: r6166 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes... | mmatthews | 14 Dec |