List:Commits« Previous MessageNext Message »
From:mmatthews Date:August 15 2006 2:30pm
Subject:Connector/J commit: r5634 - in branches: branch_5_0/connector-j branch_5_0/connector-j/src/com/mysql/jdbc branch_5_0/connector-j/src/testsuite/regress...
View as plain text  
Modified:
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
   branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
   branches/branch_5_1/connector-j/CHANGES
   branches/branch_5_1/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
   branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
Log:
Fixed BUG#21544 - When using information_schema for metadata, 
	  COLUMN_SIZE for getColumns() is not clamped to range of 
	  java.lang.Integer as is the case when not using 
	  information_schema, thus leading to a truncation exception that 
	  isn't present when not using information_schema.

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2006-08-15 00:01:35 UTC (rev 5633)
+++ branches/branch_5_0/connector-j/CHANGES	2006-08-15 14:30:36 UTC (rev 5634)
@@ -9,6 +9,12 @@
 	 between findColumn() and rsmd.getColumnName(), usually manifests itself
 	 as "Can't find column ('')" exceptions.
 	 
+	- Fixed BUG#21544 - When using information_schema for metadata, 
+	  COLUMN_SIZE for getColumns() is not clamped to range of 
+	  java.lang.Integer as is the case when not using 
+	  information_schema, thus leading to a truncation exception that 
+	  isn't present when not using information_schema.
+	 
 07-26-06 - Version 5.0.3
 
     - Fixed BUG#20650 - Statement.cancel() causes NullPointerException

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java	2006-08-15 00:01:35 UTC (rev 5633)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java	2006-08-15 14:30:36 UTC (rev 5634)
@@ -218,7 +218,9 @@
 		}
 
 		sqlBuf
-				.append("CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION ELSE CHARACTER_MAXIMUM_LENGTH END AS COLUMN_SIZE, "
+				.append("CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION ELSE CASE WHEN CHARACTER_MAXIMUM_LENGTH > " 
+						+ Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + 
+						" ELSE CHARACTER_MAXIMUM_LENGTH END END AS COLUMN_SIZE, "
 						+ " NULL AS BUFFER_LENGTH,"
 						+ "NUMERIC_SCALE AS DECIMAL_DIGITS,"
 						+ "10 AS NUM_PREC_RADIX,"

Modified: branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-08-15 00:01:35 UTC (rev 5633)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-08-15 14:30:36 UTC (rev 5634)
@@ -1539,6 +1539,49 @@
 
 		assertEquals(true, dbmd.supportsGroupByUnrelated());
 	}
+	
+	/**
+	 * Tests fix for BUG#21544 - When using information_schema for metadata, 
+	 * COLUMN_SIZE for getColumns() is not clamped to range of 
+	 * java.lang.Integer as is the case when not using 
+	 * information_schema, thus leading to a truncation exception that 
+	 * isn't present when not using information_schema.
+	 * 
+	 * @throws Exception if the test fails
+	 */
+	public void testBug21544() throws Exception {
+		if (!versionMeetsMinimum(5, 0)) {
+			return;
+		}
+		
+		createTable("testBug21544",
+                "(foo_id INT NOT NULL, stuff LONGTEXT"
+                + ", PRIMARY KEY (foo_id)) TYPE=INNODB");
+		
+		Connection infoSchemConn = null;
+		
+		Properties props = new Properties();
+		props.setProperty("useInformationSchema", "true");
+		props.setProperty("jdbcCompliantTruncation", "false");
+		
+		infoSchemConn = getConnectionWithProps(props);
+		
+		try {
+	        this.rs = infoSchemConn.getMetaData().getColumns(null, null, 
+	        		"testBug21544",
+	                null);
+	        
+	        while (rs.next()) {
+	        	rs.getInt("COLUMN_SIZE");   
+	        }
+	    } finally {
+            if (infoSchemConn != null) {
+            	infoSchemConn.close();
+            }
+            
+            closeMemberJDBCResources();
+        }
+	}
 
 	private void testAbsenceOfMetadataForQuery(String query) throws Exception {
 		try {

Modified: branches/branch_5_1/connector-j/CHANGES
===================================================================
--- branches/branch_5_1/connector-j/CHANGES	2006-08-15 00:01:35 UTC (rev 5633)
+++ branches/branch_5_1/connector-j/CHANGES	2006-08-15 14:30:36 UTC (rev 5634)
@@ -1,12 +1,31 @@
 # Changelog
 # $Id$
 
-xx-xx-06 - Version 5.1.0-alpha
+nn-nn-06 - Version 5.0.4
 
-07-nn-06 - Version 5.0.3
+   - Fixed BUG#21379 - column names don't match metadata in cases 
+     where server doesn't return original column names (column functions)
+	 thus breaking compatibility with applications that expect 1-1 mappings
+	 between findColumn() and rsmd.getColumnName(), usually manifests itself
+	 as "Can't find column ('')" exceptions.
+	 
+	- Fixed BUG#21544 - When using information_schema for metadata, 
+	  COLUMN_SIZE for getColumns() is not clamped to range of 
+	  java.lang.Integer as is the case when not using 
+	  information_schema, thus leading to a truncation exception that 
+	  isn't present when not using information_schema.
+	 
+07-26-06 - Version 5.0.3
 
     - Fixed BUG#20650 - Statement.cancel() causes NullPointerException
       if underlying connection has been closed due to server failure.
+    
+    - Added configuration option "noAccessToProcedureBodies" which will
+      cause the driver to create basic parameter metadata for
+      CallableStatements when the user does not have access to procedure
+      bodies via "SHOW CREATE PROCEDURE" or selecting from mysql.proc
+      instead of throwing an exception. The default value for this option
+      is "false".
       
 07-11-06 - Version 5.0.2-beta (5.0.1 not released due to packaging error)
 

Modified: branches/branch_5_1/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
===================================================================
--- branches/branch_5_1/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java	2006-08-15 00:01:35 UTC (rev 5633)
+++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java	2006-08-15 14:30:36 UTC (rev 5634)
@@ -218,21 +218,23 @@
 		}
 
 		sqlBuf
-				.append("CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION ELSE CHARACTER_MAXIMUM_LENGTH END AS COLUMN_SIZE, "
-						+ " NULL AS BUFFER_LENGTH,"
-						+ "NUMERIC_SCALE AS DECIMAL_DIGITS,"
-						+ "10 AS NUM_PREC_RADIX,"
-						+ "NULL AS NULLABLE,"
-						+ "COLUMN_COMMENT AS REMARKS,"
-						+ "COLUMN_DEFAULT AS COLUMN_DEF,"
-						+ "NULL AS SQL_DATA_TYPE,"
-						+ "NULL AS SQL_DATETIME_SUB,"
-						+ "CHARACTER_OCTET_LENGTH AS CHAR_OCTET_LENGTH,"
-						+ "ORDINAL_POSITION,"
-						+ "IS_NULLABLE "
-						+ "FROM INFORMATION_SCHEMA.COLUMNS WHERE "
-						+ "TABLE_SCHEMA LIKE ? AND TABLE_NAME LIKE ? AND COLUMN_NAME LIKE ? "
-						+ "ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION");
+			.append("CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION ELSE CASE WHEN CHARACTER_MAXIMUM_LENGTH > " 
+				+ Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + 
+				" ELSE CHARACTER_MAXIMUM_LENGTH END END AS COLUMN_SIZE, "
+				+ " NULL AS BUFFER_LENGTH,"
+				+ "NUMERIC_SCALE AS DECIMAL_DIGITS,"
+				+ "10 AS NUM_PREC_RADIX,"
+				+ "NULL AS NULLABLE,"
+				+ "COLUMN_COMMENT AS REMARKS,"
+				+ "COLUMN_DEFAULT AS COLUMN_DEF,"
+				+ "NULL AS SQL_DATA_TYPE,"
+				+ "NULL AS SQL_DATETIME_SUB,"
+				+ "CHARACTER_OCTET_LENGTH AS CHAR_OCTET_LENGTH,"
+				+ "ORDINAL_POSITION,"
+				+ "IS_NULLABLE "
+				+ "FROM INFORMATION_SCHEMA.COLUMNS WHERE "
+				+ "TABLE_SCHEMA LIKE ? AND TABLE_NAME LIKE ? AND COLUMN_NAME LIKE ? "
+				+ "ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION");
 
 		PreparedStatement pStmt = null;
 

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-08-15 00:01:35 UTC (rev 5633)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-08-15 14:30:36 UTC (rev 5634)
@@ -1516,4 +1516,47 @@
 		assertEquals(colName, meta.getColumnName(1));
 	
 	}
+
+	/**
+	 * Tests fix for BUG#21544 - When using information_schema for metadata, 
+	 * COLUMN_SIZE for getColumns() is not clamped to range of 
+	 * java.lang.Integer as is the case when not using 
+	 * information_schema, thus leading to a truncation exception that 
+	 * isn't present when not using information_schema.
+	 * 
+	 * @throws Exception if the test fails
+	 */
+	public void testBug21544() throws Exception {
+		if (!versionMeetsMinimum(5, 0)) {
+			return;
+		}
+		
+		createTable("testBug21544",
+	            "(foo_id INT NOT NULL, stuff LONGTEXT"
+	            + ", PRIMARY KEY (foo_id)) TYPE=INNODB");
+		
+		Connection infoSchemConn = null;
+		
+		Properties props = new Properties();
+		props.setProperty("useInformationSchema", "true");
+		props.setProperty("jdbcCompliantTruncation", "false");
+		
+		infoSchemConn = getConnectionWithProps(props);
+		
+		try {
+	        this.rs = infoSchemConn.getMetaData().getColumns(null, null, 
+	        		"testBug21544",
+	                null);
+	        
+	        while (rs.next()) {
+	        	rs.getInt("COLUMN_SIZE");   
+	        }
+	    } finally {
+	        if (infoSchemConn != null) {
+	        	infoSchemConn.close();
+	        }
+	        
+	        closeMemberJDBCResources();
+	    }
+	}
 }

Thread
Connector/J commit: r5634 - in branches: branch_5_0/connector-j branch_5_0/connector-j/src/com/mysql/jdbc branch_5_0/connector-j/src/testsuite/regress...mmatthews15 Aug