Modified:
trunk/
trunk/connector-j/CHANGES
trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java
trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
Log:
Merged revisions 6538-6540 via svnmerge from
svn+ssh://mmatthews@stripped/connectors-svnroot/connector-j/branches/branch_5_0
.......
r6540 | mmatthews | 2007-08-30 19:50:39 -0500 (Thu, 30 Aug 2007) | 3 lines
Fixed BUG#27867 - Schema objects with identifiers other than
the connection character aren't retrieved correctly in
ResultSetMetadata.
.......
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/branch_5_0:1-6537 /branches/branch_5_1:1-6517
+ /branches/branch_5_0:1-6540 /branches/branch_5_1:1-6517
Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES 2007-08-31 00:50:39 UTC (rev 6540)
+++ trunk/connector-j/CHANGES 2007-08-31 01:15:59 UTC (rev 6541)
@@ -211,7 +211,11 @@
- Fixed BUG#29852 - Closing a load-balanced connection would cause a
ClassCastException.
-
+
+ - Fixed BUG#27867 - Schema objects with identifiers other than
+ the connection character aren't retrieved correctly in
+ ResultSetMetadata.
+
07-19-07 - Version 5.0.7
- Setting the configuration parameter "useCursorFetch" to "true" for
Modified: trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java 2007-08-31 00:50:39 UTC (rev
6540)
+++ trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java 2007-08-31 01:15:59 UTC (rev
6541)
@@ -72,7 +72,9 @@
*/
public class ConnectionImpl extends ConnectionPropertiesImpl implements
Connection {
- /**
+ private static final String JDBC_LOCAL_CHARACTER_SET_RESULTS =
"jdbc.local.character_set_results";
+
+ /**
* Used as a key for caching callable statements which (may) depend on
* current catalog...In 5.0.x, they don't (currently), but stored procedure
* names soon will, so current catalog is a (hidden) component of the name.
@@ -1732,19 +1734,35 @@
// if the user hasn't 'forced' a result-set character set
//
+ String onServer = null;
+ boolean isNullOnServer = false;
+
+ if (this.serverVariables != null) {
+ onServer = (String)this.serverVariables.get("character_set_results");
+
+ isNullOnServer = onServer == null || "NULL".equalsIgnoreCase(onServer) ||
onServer.length() == 0;
+ }
+
if (getCharacterSetResults() == null) {
//
- // Only send if needed
+ // Only send if needed, if we're caching server variables
+ // we -have- to send, because we don't know what it was
+ // before we cached them.
//
-
- if (this.serverVariables.get("character_set_results") != null) {
-
+ if (!isNullOnServer) {
execSQL(null, "SET character_set_results = NULL", -1, null,
java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY, false,
this.database, null,
false);
+ if (!this.usingCachedConfig) {
+ this.serverVariables.put(JDBC_LOCAL_CHARACTER_SET_RESULTS, null);
+ }
+ } else {
+ if (!this.usingCachedConfig) {
+ this.serverVariables.put(JDBC_LOCAL_CHARACTER_SET_RESULTS, onServer);
+ }
}
} else {
String charsetResults = getCharacterSetResults();
@@ -1775,6 +1793,15 @@
java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY, false,
this.database, null, false);
+
+ if (!this.usingCachedConfig) {
+ this.serverVariables.put(JDBC_LOCAL_CHARACTER_SET_RESULTS,
+ mysqlEncodingName);
+ }
+ } else {
+ if (!this.usingCachedConfig) {
+ this.serverVariables.put(JDBC_LOCAL_CHARACTER_SET_RESULTS, onServer);
+ }
}
}
@@ -3363,13 +3390,17 @@
// out what character set metadata will be returned in,
// and then map that to a Java encoding name.
//
+ // We've already set it, and it might be different than what
+ // was originally on the server, which is why we use the
+ // "special" key to retrieve it
if (this.io.versionMeetsMinimum(4, 1, 0)) {
String characterSetResultsOnServerMysql = (String) this.serverVariables
- .get("character_set_results");
+ .get(JDBC_LOCAL_CHARACTER_SET_RESULTS);
if (characterSetResultsOnServerMysql == null
|| StringUtils.startsWithIgnoreCaseAndWs(
- characterSetResultsOnServerMysql, "NULL")) {
+ characterSetResultsOnServerMysql, "NULL")
+ || characterSetResultsOnServerMysql.length() == 0) {
String defaultMetadataCharsetMysql = (String) this.serverVariables
.get("character_set_system");
String defaultMetadataCharset = null;
@@ -3589,6 +3620,8 @@
return this.isServerTzUTC;
}
+ private boolean usingCachedConfig = false;
+
/**
* Loads the result of 'SHOW VARIABLES' into the serverVariables field so
* that the driver can configure itself.
@@ -3604,6 +3637,7 @@
if (cachedVariableMap != null) {
this.serverVariables = cachedVariableMap;
+ this.usingCachedConfig = true;
return;
}
Modified: trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2007-08-31
00:50:39 UTC (rev 6540)
+++ trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2007-08-31
01:15:59 UTC (rev 6541)
@@ -1951,4 +1951,29 @@
this.conn.prepareCall("{call testBug25624(?,?)}").close();
}
+
+ /**
+ * Tests fix for BUG#27867 - Schema objects with identifiers other than
+ * the connection character aren't retrieved correctly in ResultSetMetadata.
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug27867() throws Exception {
+ try {
+ String gbkColumnName =
"\u00e4\u00b8\u00ad\u00e6\u2013\u2021\u00e6\u00b5\u2039\u00e8\u00af\u2022";
+ createTable("ColumnNameEncoding", "(" + "`" + gbkColumnName
+ + "` varchar(1) default NULL,"
+ + "`ASCIIColumn` varchar(1) default NULL"
+ + ")ENGINE=MyISAM DEFAULT CHARSET=utf8");
+
+ this.rs = this.stmt
+ .executeQuery("SELECT * FROM ColumnNameEncoding");
+ java.sql.ResultSetMetaData tblMD = this.rs.getMetaData();
+
+ assertEquals(gbkColumnName, tblMD.getColumnName(1));
+ assertEquals("ASCIIColumn", tblMD.getColumnName(2));
+ } finally {
+ closeMemberJDBCResources();
+ }
+ }
}
| Thread |
|---|
| • Connector/J commit: r6541 - in trunk: . connector-j connector-j/src/com/mysql/jdbc connector-j/src/testsuite/regression | mmatthews | 31 Aug |