Modified:
branches/branch_5_0/connector-j/CHANGES
branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
trunk/connector-j/CHANGES
trunk/connector-j/src/com/mysql/jdbc/Connection.java
trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
Log:
Fixed BUG#27655 - Connection.getTransactionIsolation() uses
"SHOW VARIABLES LIKE" which is very inefficient on MySQL-5.0+
Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES 2007-04-02 17:46:43 UTC (rev 6372)
+++ branches/branch_5_0/connector-j/CHANGES 2007-04-05 05:38:30 UTC (rev 6373)
@@ -73,6 +73,9 @@
fill the amount of characters specified in the DDL for the column, the driver
will pad the remaining characters with space (for ANSI compliance).
+ - Fixed BUG#27655 - Connection.getTransactionIsolation() uses
+ "SHOW VARIABLES LIKE" which is very inefficient on MySQL-5.0+
+
03-01-07 - Version 5.0.5
- Fixed BUG#23645 - Some collations/character sets reported as "unknown"
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java 2007-04-02 17:46:43
UTC (rev 6372)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java 2007-04-05 05:38:30
UTC (rev 6373)
@@ -3796,16 +3796,20 @@
String query = null;
+ int offset = 0;
+
if (versionMeetsMinimum(4, 0, 3)) {
- query = "SHOW VARIABLES LIKE 'tx_isolation'";
+ query = "SELECT @@session.tx_isolation";
+ offset = 1;
} else {
query = "SHOW VARIABLES LIKE 'transaction_isolation'";
+ offset = 2;
}
rs = stmt.executeQuery(query);
if (rs.next()) {
- String s = rs.getString(2);
+ String s = rs.getString(offset);
if (s != null) {
Integer intTI = (Integer) mapTransIsolationNameToValue
@@ -3851,9 +3855,7 @@
}
}
- synchronized (this) {
- return this.isolationLevel;
- }
+ return this.isolationLevel;
}
/**
Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-04-02
17:46:43 UTC (rev 6372)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-04-05
05:38:30 UTC (rev 6373)
@@ -2030,4 +2030,33 @@
}
}
}
-}
+
+ /**
+ * Tests fix for BUG#27655 - getTransactionIsolation() uses
+ * "SHOW VARIABLES LIKE" which is very inefficient on MySQL-5.0+
+ *
+ * @throws Exception
+ */
+ public void testBug27655() throws Exception {
+ StringBuffer logBuf = new StringBuffer();
+ Properties props = new Properties();
+ props.setProperty("profileSQL", "true");
+ props.setProperty("logger", "StandardLogger");
+ StandardLogger.bufferedLog = logBuf;
+
+ Connection loggedConn = null;
+
+ try {
+ loggedConn = getConnectionWithProps(props);
+ loggedConn.getTransactionIsolation();
+
+ if (versionMeetsMinimum(4, 0, 3)) {
+ assertEquals(-1, logBuf.indexOf("SHOW VARIABLES LIKE 'tx_isolation'"));
+ }
+ } finally {
+ if (loggedConn != null) {
+ loggedConn.close();
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES 2007-04-02 17:46:43 UTC (rev 6372)
+++ trunk/connector-j/CHANGES 2007-04-05 05:38:30 UTC (rev 6373)
@@ -97,7 +97,10 @@
to "true", and a result set column has the CHAR type and the value does not
fill the amount of characters specified in the DDL for the column, the driver
will pad the remaining characters with space (for ANSI compliance).
-
+
+ - Fixed BUG#27655 - Connection.getTransactionIsolation() uses
+ "SHOW VARIABLES LIKE" which is very inefficient on MySQL-5.0+
+
03-01-07 - Version 5.0.5
- Fixed BUG#23645 - Some collations/character sets reported as "unknown"
Modified: trunk/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/Connection.java 2007-04-02 17:46:43 UTC (rev
6372)
+++ trunk/connector-j/src/com/mysql/jdbc/Connection.java 2007-04-05 05:38:30 UTC (rev
6373)
@@ -3030,9 +3030,7 @@
}
}
- synchronized (this) {
- return this.isolationLevel;
- }
+ return this.isolationLevel;
}
/**
Modified: trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-04-02
17:46:43 UTC (rev 6372)
+++ trunk/connector-j/src/testsuite/regression/ConnectionRegressionTest.java 2007-04-05
05:38:30 UTC (rev 6373)
@@ -2030,4 +2030,33 @@
}
}
}
+
+ /**
+ * Tests fix for BUG#27655 - getTransactionIsolation() uses
+ * "SHOW VARIABLES LIKE" which is very inefficient on MySQL-5.0+
+ *
+ * @throws Exception
+ */
+ public void testBug27655() throws Exception {
+ StringBuffer logBuf = new StringBuffer();
+ Properties props = new Properties();
+ props.setProperty("profileSQL", "true");
+ props.setProperty("logger", "StandardLogger");
+ StandardLogger.bufferedLog = logBuf;
+
+ Connection loggedConn = null;
+
+ try {
+ loggedConn = getConnectionWithProps(props);
+ loggedConn.getTransactionIsolation();
+
+ if (versionMeetsMinimum(4, 0, 3)) {
+ assertEquals(-1, logBuf.indexOf("SHOW VARIABLES LIKE 'tx_isolation'"));
+ }
+ } finally {
+ if (loggedConn != null) {
+ loggedConn.close();
+ }
+ }
+ }
}
| Thread |
|---|
| • Connector/J commit: r6373 - 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 | 5 Apr |