Modified:
trunk/
trunk/connector-j/CHANGES
trunk/connector-j/src/com/mysql/jdbc/Connection.java
trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java
trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java
trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java
trunk/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties
trunk/connector-j/src/com/mysql/jdbc/ResultSetMetaData.java
trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
Log:
Merged revisions 6597-6601 via svnmerge from
svn+ssh://mmatthews@stripped/connectors-svnroot/connector-j/branches/branch_5_0
.......
r6599 | mmatthews | 2007-10-02 17:34:20 -0500 (Tue, 02 Oct 2007) | 3 lines
Driver will now fall back to sane defaults for max_allowed_packet and
net_buffer_length if the server reports them incorrectly (and will log
this situation at WARN level, since it's actually an error condition).
.......
r6600 | mmatthews | 2007-10-02 17:35:59 -0500 (Tue, 02 Oct 2007) | 1 line
Off by one error in error message indexing.
.......
r6601 | mmatthews | 2007-10-03 09:24:12 -0500 (Wed, 03 Oct 2007) | 6 lines
Fixed BUG#27916 - UNSIGNED types not reported via DBMD.getTypeInfo(), and
capitalization of type names is not consistent between DBMD.getColumns(),
RSMD.getColumnTypeName() and DBMD.getTypeInfo().
This fix also ensures that the precision of UNSIGNED MEDIUMINT
and UNSIGNED BIGINT is reported correctly via DBMD.getColumns().
.......
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/branch_5_0:1-6596 /branches/branch_5_1:1-6566,6576-6577,6584
+ /branches/branch_5_0:1-6601 /branches/branch_5_1:1-6566,6576-6577,6584
Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES 2007-10-03 14:24:12 UTC (rev 6601)
+++ trunk/connector-j/CHANGES 2007-10-03 14:51:58 UTC (rev 6602)
@@ -273,7 +273,18 @@
- Fixed Bug#27412 - cached metadata with PreparedStatement.execute()
throws NullPointerException.
-
+
+ - Driver will now fall back to sane defaults for max_allowed_packet and
+ net_buffer_length if the server reports them incorrectly (and will log
+ this situation at WARN level, since it's actually an error condition).
+
+ - Fixed BUG#27916 - UNSIGNED types not reported via DBMD.getTypeInfo(), and
+ capitalization of type names is not consistent between DBMD.getColumns(),
+ RSMD.getColumnTypeName() and DBMD.getTypeInfo().
+
+ This fix also ensures that the precision of UNSIGNED MEDIUMINT
+ and UNSIGNED BIGINT is reported correctly via DBMD.getColumns().
+
07-19-07 - Version 5.0.7
- Setting the configuration parameter "useCursorFetch" to "true" for
Modified: trunk/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/Connection.java 2007-10-03 14:24:12 UTC (rev
6601)
+++ trunk/connector-j/src/com/mysql/jdbc/Connection.java 2007-10-03 14:51:58 UTC (rev
6602)
@@ -348,4 +348,4 @@
public abstract boolean isAbonormallyLongQuery(long millisOrNanos);
-}
\ No newline at end of file
+}
Modified: trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java 2007-10-03 14:24:12 UTC (rev
6601)
+++ trunk/connector-j/src/com/mysql/jdbc/ConnectionImpl.java 2007-10-03 14:51:58 UTC (rev
6602)
@@ -3352,9 +3352,7 @@
configureTimezone();
if (this.serverVariables.containsKey("max_allowed_packet")) {
- this.maxAllowedPacket = Integer
- .parseInt((String) this.serverVariables
- .get("max_allowed_packet"));
+ this.maxAllowedPacket = getServerVariableAsInt("max_allowed_packet", 1024 * 1024);
int preferredBlobSendChunkSize = getBlobSendChunkSize();
@@ -3367,9 +3365,7 @@
}
if (this.serverVariables.containsKey("net_buffer_length")) {
- this.netBufferLength = Integer
- .parseInt((String) this.serverVariables
- .get("net_buffer_length"));
+ this.netBufferLength = getServerVariableAsInt("net_buffer_length", 16 * 1024);
}
checkTransactionIsolationLevel();
@@ -3501,6 +3497,19 @@
setupServerForTruncationChecks();
}
+ private int getServerVariableAsInt(String variableName, int fallbackValue)
+ throws SQLException {
+ try {
+ return Integer.parseInt((String) this.serverVariables
+ .get(variableName));
+ } catch (NumberFormatException nfe) {
+ getLog().logWarn(Messages.getString("Connection.BadValueInServerVariables", new
Object[] {variableName,
+ this.serverVariables.get(variableName), new Integer(fallbackValue)}));
+
+ return fallbackValue;
+ }
+ }
+
/**
* Has the default autocommit value of 0 been changed on the server
* via init_connect?
Modified: trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java 2007-10-03 14:24:12
UTC (rev 6601)
+++ trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java 2007-10-03 14:51:58
UTC (rev 6602)
@@ -755,19 +755,16 @@
Messages.getString("ConnectionProperties.blobSendChunkSize"), //$NON-NLS-1$
"3.1.9", PERFORMANCE_CATEGORY, Integer.MIN_VALUE); //$NON-NLS-1$
- private BooleanConnectionProperty autoSlowLog = new BooleanConnectionProperty(
- "autoSlowLog", true,
- Messages.getString("ConnectionProperties.autoSlowLog"),
- "5.1.4", DEBUGING_PROFILING_CATEGORY, Integer.MIN_VALUE);
-
private BooleanConnectionProperty blobsAreStrings = new BooleanConnectionProperty(
"blobsAreStrings", false,
- Messages.getString("ConnectionProperties.blobsAreStrings"),
+ "Should the driver always treat BLOBs as Strings - specifically to work
around dubious metadata "
+ + "returned by the server for GROUP BY clauses?",
"5.0.8", MISC_CATEGORY, Integer.MIN_VALUE);
private BooleanConnectionProperty functionsNeverReturnBlobs = new
BooleanConnectionProperty(
"functionsNeverReturnBlobs", false,
- Messages.getString("ConnectionProperties.functionsNeverReturnBlobs"),
+ "Should the driver always treat data from functions returning BLOBs as
Strings - specifically to work around dubious metadata "
+ + "returned by the server for GROUP BY clauses?",
"5.0.8", MISC_CATEGORY, Integer.MIN_VALUE);
private BooleanConnectionProperty cacheCallableStatements = new
BooleanConnectionProperty(
@@ -805,7 +802,7 @@
private BooleanConnectionProperty capitalizeTypeNames = new BooleanConnectionProperty(
"capitalizeTypeNames", //$NON-NLS-1$
- false,
+ true,
Messages.getString("ConnectionProperties.capitalizeTypeNames"), //$NON-NLS-1$
"2.0.7", MISC_CATEGORY, Integer.MIN_VALUE); //$NON-NLS-1$
@@ -846,12 +843,6 @@
Messages.getString("ConnectionProperties.connectionCollation"), //$NON-NLS-1$
"3.0.13", MISC_CATEGORY, 7); //$NON-NLS-1$
- private StringConnectionProperty connectionLifecycleInterceptors = new
StringConnectionProperty(
- "connectionLifecycleInterceptors", //$NON-NLS-1$
- null,
- Messages.getString("ConnectionProperties.connectionLifecycleInterceptors"),
- "5.1.4", CONNECTION_AND_AUTH_CATEGORY, Integer.MAX_VALUE);
-
private IntegerConnectionProperty connectTimeout = new IntegerConnectionProperty(
"connectTimeout", 0, 0, Integer.MAX_VALUE, //$NON-NLS-1$
Messages.getString("ConnectionProperties.connectTimeout"), //$NON-NLS-1$
@@ -4265,20 +4256,4 @@
public void setFunctionsNeverReturnBlobs(boolean flag) {
this.functionsNeverReturnBlobs.setValue(flag);
}
-
- public boolean getAutoSlowLog() {
- return this.autoSlowLog.getValueAsBoolean();
- }
-
- public void setAutoSlowLog(boolean flag) {
- this.autoSlowLog.setValue(flag);
- }
-
- public String getConnectionLifecycleInterceptors() {
- return this.connectionLifecycleInterceptors.getValueAsString();
- }
-
- public void setConnectionLifecycleInterceptors(String interceptors) {
- this.connectionLifecycleInterceptors.setValue(interceptors);
- }
}
Modified: trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java 2007-10-03 14:24:12 UTC
(rev 6601)
+++ trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java 2007-10-03 14:51:58 UTC
(rev 6602)
@@ -193,8 +193,11 @@
// Add unsigned to typename reported to enduser as 'native type', if
// present
+ boolean isUnsigned = false;
+
if (StringUtils.indexOfIgnoreCase(typeInfo, "unsigned") != -1) {
fullMysqlType = mysqlType + " unsigned";
+ isUnsigned = true;
} else {
fullMysqlType = mysqlType;
}
@@ -304,7 +307,7 @@
this.decimalDigits = Constants.integerValueOf(0);
} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo,
"mediumint")) {
- this.columnSize = Constants.integerValueOf(7);
+ this.columnSize = Constants.integerValueOf(isUnsigned ? 8 : 7);
this.decimalDigits = Constants.integerValueOf(0);
} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo,
"int")) {
@@ -316,7 +319,7 @@
this.decimalDigits = Constants.integerValueOf(0);
} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo,
"bigint")) {
- this.columnSize = Constants.integerValueOf(19);
+ this.columnSize = Constants.integerValueOf(isUnsigned ? 20 : 19);
this.decimalDigits = Constants.integerValueOf(0);
} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo,
"int24")) {
@@ -5253,7 +5256,36 @@
rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
tuples.add(new ByteArrayRow(rowVal));
+
+ rowVal = new byte[18][];
+ rowVal[0] = s2b("TINYINT UNSIGNED");
+ rowVal[1] = Integer.toString(java.sql.Types.TINYINT).getBytes();
+ // JDBC Data type
+ rowVal[2] = s2b("3"); // Precision
+ rowVal[3] = s2b(""); // Literal Prefix
+ rowVal[4] = s2b(""); // Literal Suffix
+ rowVal[5] = s2b("[(M)] [UNSIGNED] [ZEROFILL]"); // Create Params
+ rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
+ .getBytes();
+
+ // Nullable
+ rowVal[7] = s2b("false"); // Case Sensitive
+ rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
+ .getBytes();
+
+ // Searchable
+ rowVal[9] = s2b("true"); // Unsignable
+ rowVal[10] = s2b("false"); // Fixed Prec Scale
+ rowVal[11] = s2b("true"); // Auto Increment
+ rowVal[12] = s2b("TINYINT UNSIGNED"); // Locale Type Name
+ rowVal[13] = s2b("0"); // Minimum Scale
+ rowVal[14] = s2b("0"); // Maximum Scale
+ rowVal[15] = s2b("0"); // SQL Data Type (not used)
+ rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
+ rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
+ tuples.add(rowVal);
+
/*
* MySQL Type: BIGINT JDBC Type: BIGINT
*/
@@ -5285,7 +5317,36 @@
rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
tuples.add(new ByteArrayRow(rowVal));
+
+ rowVal = new byte[18][];
+ rowVal[0] = s2b("BIGINT UNSIGNED");
+ rowVal[1] = Integer.toString(java.sql.Types.BIGINT).getBytes();
+ // JDBC Data type
+ rowVal[2] = s2b("20"); // Precision
+ rowVal[3] = s2b(""); // Literal Prefix
+ rowVal[4] = s2b(""); // Literal Suffix
+ rowVal[5] = s2b("[(M)] [ZEROFILL]"); // Create Params
+ rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
+ .getBytes();
+
+ // Nullable
+ rowVal[7] = s2b("false"); // Case Sensitive
+ rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
+ .getBytes();
+
+ // Searchable
+ rowVal[9] = s2b("true"); // Unsignable
+ rowVal[10] = s2b("false"); // Fixed Prec Scale
+ rowVal[11] = s2b("true"); // Auto Increment
+ rowVal[12] = s2b("BIGINT UNSIGNED"); // Locale Type Name
+ rowVal[13] = s2b("0"); // Minimum Scale
+ rowVal[14] = s2b("0"); // Maximum Scale
+ rowVal[15] = s2b("0"); // SQL Data Type (not used)
+ rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
+ rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
+ tuples.add(rowVal);
+
/*
* MySQL Type: LONG VARBINARY JDBC Type: LONGVARBINARY
*/
@@ -5816,7 +5877,36 @@
rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
tuples.add(new ByteArrayRow(rowVal));
+
+ rowVal = new byte[18][];
+ rowVal[0] = s2b("INTEGER UNSIGNED");
+ rowVal[1] = Integer.toString(java.sql.Types.INTEGER).getBytes();
+ // JDBC Data type
+ rowVal[2] = s2b("10"); // Precision
+ rowVal[3] = s2b(""); // Literal Prefix
+ rowVal[4] = s2b(""); // Literal Suffix
+ rowVal[5] = s2b("[(M)] [ZEROFILL]"); // Create Params
+ rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
+ .getBytes();
+
+ // Nullable
+ rowVal[7] = s2b("false"); // Case Sensitive
+ rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
+ .getBytes();
+
+ // Searchable
+ rowVal[9] = s2b("true"); // Unsignable
+ rowVal[10] = s2b("false"); // Fixed Prec Scale
+ rowVal[11] = s2b("true"); // Auto Increment
+ rowVal[12] = s2b("INTEGER UNSIGNED"); // Locale Type Name
+ rowVal[13] = s2b("0"); // Minimum Scale
+ rowVal[14] = s2b("0"); // Maximum Scale
+ rowVal[15] = s2b("0"); // SQL Data Type (not used)
+ rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
+ rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
+ tuples.add(rowVal);
+
/*
* MySQL Type: INT JDBC Type: INTEGER
*/
@@ -5848,7 +5938,36 @@
rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
tuples.add(new ByteArrayRow(rowVal));
+
+ rowVal = new byte[18][];
+ rowVal[0] = s2b("INT UNSIGNED");
+ rowVal[1] = Integer.toString(java.sql.Types.INTEGER).getBytes();
+ // JDBC Data type
+ rowVal[2] = s2b("10"); // Precision
+ rowVal[3] = s2b(""); // Literal Prefix
+ rowVal[4] = s2b(""); // Literal Suffix
+ rowVal[5] = s2b("[(M)] [ZEROFILL]"); // Create Params
+ rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
+ .getBytes();
+
+ // Nullable
+ rowVal[7] = s2b("false"); // Case Sensitive
+ rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
+ .getBytes();
+
+ // Searchable
+ rowVal[9] = s2b("true"); // Unsignable
+ rowVal[10] = s2b("false"); // Fixed Prec Scale
+ rowVal[11] = s2b("true"); // Auto Increment
+ rowVal[12] = s2b("INT UNSIGNED"); // Locale Type Name
+ rowVal[13] = s2b("0"); // Minimum Scale
+ rowVal[14] = s2b("0"); // Maximum Scale
+ rowVal[15] = s2b("0"); // SQL Data Type (not used)
+ rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
+ rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
+ tuples.add(rowVal);
+
/*
* MySQL Type: MEDIUMINT JDBC Type: INTEGER
*/
@@ -5881,6 +6000,35 @@
rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
tuples.add(new ByteArrayRow(rowVal));
+ rowVal = new byte[18][];
+ rowVal[0] = s2b("MEDIUMINT UNSIGNED");
+ rowVal[1] = Integer.toString(java.sql.Types.INTEGER).getBytes();
+
+ // JDBC Data type
+ rowVal[2] = s2b("8"); // Precision
+ rowVal[3] = s2b(""); // Literal Prefix
+ rowVal[4] = s2b(""); // Literal Suffix
+ rowVal[5] = s2b("[(M)] [ZEROFILL]"); // Create Params
+ rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
+ .getBytes();
+
+ // Nullable
+ rowVal[7] = s2b("false"); // Case Sensitive
+ rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
+ .getBytes();
+
+ // Searchable
+ rowVal[9] = s2b("true"); // Unsignable
+ rowVal[10] = s2b("false"); // Fixed Prec Scale
+ rowVal[11] = s2b("true"); // Auto Increment
+ rowVal[12] = s2b("MEDIUMINT UNSIGNED"); // Locale Type Name
+ rowVal[13] = s2b("0"); // Minimum Scale
+ rowVal[14] = s2b("0"); // Maximum Scale
+ rowVal[15] = s2b("0"); // SQL Data Type (not used)
+ rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
+ rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
+ tuples.add(rowVal);
+
/*
* MySQL Type: SMALLINT JDBC Type: SMALLINT
*/
@@ -5912,7 +6060,36 @@
rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
tuples.add(new ByteArrayRow(rowVal));
+
+ rowVal = new byte[18][];
+ rowVal[0] = s2b("SMALLINT UNSIGNED");
+ rowVal[1] = Integer.toString(java.sql.Types.SMALLINT).getBytes();
+ // JDBC Data type
+ rowVal[2] = s2b("5"); // Precision
+ rowVal[3] = s2b(""); // Literal Prefix
+ rowVal[4] = s2b(""); // Literal Suffix
+ rowVal[5] = s2b("[(M)] [ZEROFILL]"); // Create Params
+ rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
+ .getBytes();
+
+ // Nullable
+ rowVal[7] = s2b("false"); // Case Sensitive
+ rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
+ .getBytes();
+
+ // Searchable
+ rowVal[9] = s2b("true"); // Unsignable
+ rowVal[10] = s2b("false"); // Fixed Prec Scale
+ rowVal[11] = s2b("true"); // Auto Increment
+ rowVal[12] = s2b("SMALLINT UNSIGNED"); // Locale Type Name
+ rowVal[13] = s2b("0"); // Minimum Scale
+ rowVal[14] = s2b("0"); // Maximum Scale
+ rowVal[15] = s2b("0"); // SQL Data Type (not used)
+ rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
+ rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
+ tuples.add(rowVal);
+
/*
* MySQL Type: FLOAT JDBC Type: REAL (this is the SINGLE PERCISION
* floating point type)
Modified: trunk/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties 2007-10-03
14:24:12 UTC (rev 6601)
+++ trunk/connector-j/src/com/mysql/jdbc/LocalizedErrorMessages.properties 2007-10-03
14:51:58 UTC (rev 6602)
@@ -420,6 +420,7 @@
JDBC4Connection.ClientInfoNotImplemented=Configured clientInfoProvider class '{0}' does
not implement com.mysql.jdbc.JDBC4ClientInfoProvider.
InvalidLoadBalanceStrategy=Invalid load balancing strategy '{0}'.
+Connection.Connection.BadValueInServerVariables=Invalid value '{1}' for server variable
named '{0}', falling back to sane default of '{2}'.
#
# ConnectionProperty Categories
Modified: trunk/connector-j/src/com/mysql/jdbc/ResultSetMetaData.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/ResultSetMetaData.java 2007-10-03 14:24:12 UTC
(rev 6601)
+++ trunk/connector-j/src/com/mysql/jdbc/ResultSetMetaData.java 2007-10-03 14:51:58 UTC
(rev 6602)
@@ -303,7 +303,7 @@
return field.isUnsigned() ? "SMALLINT UNSIGNED" : "SMALLINT";
case MysqlDefs.FIELD_TYPE_LONG:
- return field.isUnsigned() ? "INTEGER UNSIGNED" : "INTEGER";
+ return field.isUnsigned() ? "INT UNSIGNED" : "INT";
case MysqlDefs.FIELD_TYPE_FLOAT:
return field.isUnsigned() ? "FLOAT UNSIGNED" : "FLOAT";
Modified: trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2007-10-03
14:24:12 UTC (rev 6601)
+++ trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2007-10-03
14:51:58 UTC (rev 6602)
@@ -2025,4 +2025,46 @@
assertNull(this.rs.getString("SOURCE_DATA_TYPE"));
assertEquals("NO", this.rs.getString("IS_AUTOINCREMENT"));
}
+
+ /**
+ * Tests fix for BUG#27916 - UNSIGNED types not reported
+ * via DBMD.getTypeInfo(), and capitalization of types is
+ * not consistent between DBMD.getColumns(), RSMD.getColumnTypeName()
+ * and DBMD.getTypeInfo().
+ *
+ * This fix also ensures that the precision of UNSIGNED MEDIUMINT
+ * and UNSIGNED BIGINT is reported correctly via DBMD.getColumns().
+ *
+ * @throws Exception
+ */
+ public void testBug27916() throws Exception {
+ createTable(
+ "testBug27916",
+ "(field1 TINYINT UNSIGNED, field2 SMALLINT UNSIGNED, field3 INT UNSIGNED, field4
INTEGER UNSIGNED, field5 MEDIUMINT UNSIGNED, field6 BIGINT UNSIGNED)");
+
+ ResultSetMetaData rsmd = this.stmt.executeQuery(
+ "SELECT * FROM testBug27916").getMetaData();
+
+ HashMap typeNameToPrecision = new HashMap();
+ this.rs = this.conn.getMetaData().getTypeInfo();
+
+ while (this.rs.next()) {
+ typeNameToPrecision.put(this.rs.getString("TYPE_NAME"), this.rs
+ .getObject("PRECISION"));
+ }
+
+ this.rs = this.conn.getMetaData().getColumns(this.conn.getCatalog(),
+ null, "testBug27916", "%");
+
+ for (int i = 0; i < rsmd.getColumnCount(); i++) {
+ this.rs.next();
+ String typeName = this.rs.getString("TYPE_NAME");
+
+ assertEquals(typeName, rsmd.getColumnTypeName(i + 1));
+ assertEquals(typeName, this.rs.getInt("COLUMN_SIZE"), rsmd
+ .getPrecision(i + 1));
+ assertEquals(typeName, new Integer(rsmd.getPrecision(i + 1)),
+ typeNameToPrecision.get(typeName));
+ }
+ }
}
| Thread |
|---|
| • Connector/J commit: r6602 - in trunk: . connector-j connector-j/src/com/mysql/jdbc connector-j/src/testsuite/regression | mmatthews | 3 Oct |