742 Todd Farmer 2008-10-15
BUG#40031 - Adding support for CallableStatement.execute() to call stored procedures that are defined as NO SQL or SQL READ DATA when failed over to a read-only slave with replication driver.
modified:
CHANGES
src/com/mysql/jdbc/CallableStatement.java
741 Todd Farmer 2008-10-14
BUG#40031 - allow CallableStatement.execute() to call a stored procedure that has been defined as NO SQL or SQL READ DATA.
added:
src/testsuite/simple/ReadOnlyCallableStatementTest.java
modified:
src/com/mysql/jdbc/CallableStatement.java
src/com/mysql/jdbc/DatabaseMetaData.java
src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
src/com/mysql/jdbc/PreparedStatement.java
src/testsuite/regression/ConnectionRegressionTest.java
=== modified file 'CHANGES'
--- a/CHANGES 2008-10-13 16:46:27 +0000
+++ b/CHANGES 2008-10-15 21:21:14 +0000
@@ -2,6 +2,20 @@
# $Id$
nn-nn-08 - Version 5.1.7
+ - Fixed BUG#33861 - Added global blacklist for LoadBalancingConnectionProxy and
+ implemented in RandomBalanceStrategy and BestResponseTimeBalanceStrategy.
+ Added new property, "loadBalanceBlacklistTimeout", to control how long a
+ server lives in the global blacklist.
+
+ - Fixed BUG#38782 - Possible IndexOutOfBoundsException in random load balancing
+ strategy.
+
+ - Fixed BUG#39784 - invalidateCurrentConnection() does not manage global blacklist
+ when handling connection exceptions.
+
+ - Fixed BUG#40031 - Adding support for CallableStatement.execute() to call
+ stored procedures that are defined as NO SQL or SQL READ DATA when failed
+ over to a read-only slave with replication driver.
- Fixed BUG#35170- ResultSet.isAfterLast() doesn't work with for
streaming result sets.
=== modified file 'src/com/mysql/jdbc/CallableStatement.java'
--- a/src/com/mysql/jdbc/CallableStatement.java 2008-10-15 05:12:44 +0000
+++ b/src/com/mysql/jdbc/CallableStatement.java 2008-10-15 21:21:14 +0000
@@ -149,8 +149,15 @@ public class CallableStatement extends P
Map parameterMap;
+
+ /**
+ * synchronized externally in checkReadOnlyProcedure()
+ */
boolean isReadOnlySafeProcedure = false;
+ /**
+ * synchronized externally in checkReadOnlyProcedure()
+ */
boolean isReadOnlySafeChecked = false;
/**
@@ -2371,50 +2378,58 @@ public class CallableStatement extends P
if (this.connection.getNoAccessToProcedureBodies()) {
return false;
}
-
- synchronized(this.paramInfo){
- if(this.paramInfo.isReadOnlySafeChecked){
+
+ synchronized (this.paramInfo) {
+ if (this.paramInfo.isReadOnlySafeChecked) {
return this.paramInfo.isReadOnlySafeProcedure;
}
- }
-
- ResultSet rs = null;
- try {
- String procName = extractProcedureName();
-
- String catalog = this.currentCatalog;
-
- if (procName.indexOf(".") != -1) {
- catalog = procName.substring(0, procName.indexOf("."));
- procName = procName.substring(procName.indexOf(".") + 1);
- procName = new String(StringUtils.stripEnclosure(procName.getBytes(), "`", "`"));
- }
- PreparedStatement ps = ((DatabaseMetaData) this.connection.getMetaData()).prepareMetaDataSafeStatement(
- "SELECT SQL_DATA_ACCESS FROM "
- + " information_schema.routines "
- + " WHERE routine_schema = ? "
- + " AND routine_name = ?");
+ ResultSet rs = null;
+ PreparedStatement ps = null;
- ps.setString(1, catalog);
- ps.setString(2, procName);
- rs = ps.executeQuery();
- if(rs.next()) {
- String sqlDataAccess = rs.getString(1);
- rs.close();
- ps.close();
- if(sqlDataAccess.equals("READS SQL DATA") || sqlDataAccess.equals("NO SQL")){
- synchronized(this.paramInfo){
- this.paramInfo.isReadOnlySafeChecked = true;
- this.paramInfo.isReadOnlySafeProcedure = true;
+ try {
+ String procName = extractProcedureName();
+
+ String catalog = this.currentCatalog;
+
+ if (procName.indexOf(".") != -1) {
+ catalog = procName.substring(0, procName.indexOf("."));
+ procName = procName.substring(procName.indexOf(".") + 1);
+ procName = new String(StringUtils.stripEnclosure(procName
+ .getBytes(), "`", "`"));
+ }
+ ps = ((DatabaseMetaData) this.connection
+ .getMetaData())
+ .prepareMetaDataSafeStatement("SELECT SQL_DATA_ACCESS FROM "
+ + " information_schema.routines "
+ + " WHERE routine_schema = ? "
+ + " AND routine_name = ?");
+
+ ps.setString(1, catalog);
+ ps.setString(2, procName);
+ rs = ps.executeQuery();
+ if (rs.next()) {
+ String sqlDataAccess = rs.getString(1);
+ if ("READS SQL DATA".equalsIgnoreCase(sqlDataAccess)
+ || "NO SQL".equalsIgnoreCase(sqlDataAccess)) {
+ synchronized (this.paramInfo) {
+ this.paramInfo.isReadOnlySafeChecked = true;
+ this.paramInfo.isReadOnlySafeProcedure = true;
+ }
+ return true;
}
- return true;
}
+ } catch (SQLException e) {
+ // swallow the Exception
+ } finally {
+ if(rs != null){
+ rs.close();
+ }
+ if(ps != null){
+ ps.close();
+ }
+
}
- } catch (SQLException e) {
- // swallow the Exception
- }
- synchronized(this.paramInfo){
this.paramInfo.isReadOnlySafeChecked = false;
this.paramInfo.isReadOnlySafeProcedure = false;
}
| Thread |
|---|
| • bzr push into connector-j/branches/branch_5_1 branch (todd.farmer:741to 742) Bug#40031 | Todd Farmer | 15 Oct |