MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mmatthews Date:December 7 2006 10:47pm
Subject:Connector/J commit: r6133 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...
View as plain text  
Modified:
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
   branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
   trunk/connector-j/CHANGES
   trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java
   trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
   trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
Log:
Fixed BUG#23304 - DBMD using "show" and DBMD using information_schema do 
      not return results consistent with each other. (note this fix only 
      addresses the inconsistencies, not the issue that the driver is 
      treating schemas differently than some users expect. We will revisit 
      this behavior when there is full support for schemas in MySQL).  

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2006-12-07 22:06:30 UTC (rev 6132)
+++ branches/branch_5_0/connector-j/CHANGES	2006-12-07 22:47:38 UTC (rev 6133)
@@ -16,8 +16,7 @@
       columns not referenced in them.
       
     - Fixed BUG#24360 .setFetchSize() breaks prepared SHOW and other commands.
-
-          
+         
     - Fixed BUG#24344 - useJDBCCompliantTimezoneShift with server-side prepared
 	  statements gives different behavior than when using client-side prepared
 	  statements. (this is now fixed if moving from server-side prepared statements
@@ -25,7 +24,13 @@
 	  true", as the driver can't tell if this is a new deployment that never used 
 	  server-side prepared statements, or if it is an existing deployment that is
 	  switching to client-side prepared statements from server-side prepared statements.
-	         
+
+    - Fixed BUG#23304 - DBMD using "show" and DBMD using information_schema do 
+      not return results consistent with each other. (note this fix only 
+      addresses the inconsistencies, not the issue that the driver is 
+      treating schemas differently than some users expect. We will revisit 
+      this behavior when there is full support for schemas in MySQL).  
+             
 10-20-06 - Version 5.0.4
 
     - Fixed BUG#21379 - column names don't match metadata in cases 

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java	2006-12-07 22:06:30 UTC (rev 6132)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java	2006-12-07 22:47:38 UTC (rev 6133)
@@ -168,11 +168,11 @@
 
 		int charOctetLength;
 
-		int columnSize;
+		Integer columnSize;
 
 		short dataType;
 
-		int decimalDigits;
+		Integer decimalDigits;
 
 		String isNullable;
 
@@ -232,8 +232,8 @@
 								.length() - 2));
 					}
 
-					this.columnSize = maxLength;
-					this.decimalDigits = 0;
+					this.columnSize = new Integer(maxLength);
+					this.decimalDigits = null;
 				} else if (StringUtils.startsWithIgnoreCase(typeInfo, "set")) {
 					String temp = typeInfo.substring(typeInfo.indexOf("("),
 							typeInfo.lastIndexOf(")"));
@@ -251,33 +251,38 @@
 						}
 					}
 
-					this.columnSize = maxLength;
-					this.decimalDigits = 0;
+					this.columnSize = new Integer(maxLength);
+					this.decimalDigits = null;
 				} else if (typeInfo.indexOf(",") != -1) {
 					// Numeric with decimals
-					this.columnSize = Integer.parseInt(typeInfo.substring(
+					this.columnSize = new Integer(typeInfo.substring(
 							(typeInfo.indexOf("(") + 1),
 							(typeInfo.indexOf(","))));
-					this.decimalDigits = Integer.parseInt(typeInfo.substring(
+					this.decimalDigits = new Integer(typeInfo.substring(
 							(typeInfo.indexOf(",") + 1),
 							(typeInfo.indexOf(")"))));
 				} else {
-					this.columnSize = 0;
-
+					this.columnSize = null;
+					this.decimalDigits = null;
+					
 					/* If the size is specified with the DDL, use that */
-					if (typeInfo.indexOf("(") != -1) {
+					if ((StringUtils.indexOfIgnoreCase(typeInfo, "char") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "text") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "blob") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "binary") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "bit") != -1) && typeInfo.indexOf("(") != -1) {
 						int endParenIndex = typeInfo.indexOf(")");
 
 						if (endParenIndex == -1) {
 							endParenIndex = typeInfo.length();
 						}
 
-						this.columnSize = Integer.parseInt(typeInfo.substring(
+						this.columnSize = new Integer(typeInfo.substring(
 								(typeInfo.indexOf("(") + 1), endParenIndex));
 
 						// Adjust for pseudo-boolean
 						if (conn.getTinyInt1isBit()
-								&& this.columnSize == 1
+								&& this.columnSize.intValue() == 1
 								&& StringUtils.startsWithIgnoreCase(typeInfo,
 										0, "tinyint")) {
 							if (conn.getTransformedBitIsBoolean()) {
@@ -288,69 +293,75 @@
 								this.typeName = "BIT";
 							}
 						}
-					} else if (typeInfo.equalsIgnoreCase("tinyint")) {
-						this.columnSize = 1;
-					} else if (typeInfo.equalsIgnoreCase("smallint")) {
-						this.columnSize = 6;
-					} else if (typeInfo.equalsIgnoreCase("mediumint")) {
-						this.columnSize = 6;
-					} else if (typeInfo.equalsIgnoreCase("int")) {
-						this.columnSize = 11;
-					} else if (typeInfo.equalsIgnoreCase("integer")) {
-						this.columnSize = 11;
-					} else if (typeInfo.equalsIgnoreCase("bigint")) {
-						this.columnSize = 25;
-					} else if (typeInfo.equalsIgnoreCase("int24")) {
-						this.columnSize = 25;
-					} else if (typeInfo.equalsIgnoreCase("real")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("float")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("decimal")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("numeric")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("double")) {
-						this.columnSize = 22;
-					} else if (typeInfo.equalsIgnoreCase("char")) {
-						this.columnSize = 1;
-					} else if (typeInfo.equalsIgnoreCase("varchar")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("date")) {
-						this.columnSize = 10;
-					} else if (typeInfo.equalsIgnoreCase("time")) {
-						this.columnSize = 8;
-					} else if (typeInfo.equalsIgnoreCase("timestamp")) {
-						this.columnSize = 19;
-					} else if (typeInfo.equalsIgnoreCase("datetime")) {
-						this.columnSize = 19;
-					} else if (typeInfo.equalsIgnoreCase("tinyblob")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("blob")) {
-						this.columnSize = 65535;
-					} else if (typeInfo.equalsIgnoreCase("mediumblob")) {
-						this.columnSize = 16277215;
-					} else if (typeInfo.equalsIgnoreCase("longblob")) {
-						this.columnSize = Integer.MAX_VALUE;
-					} else if (typeInfo.equalsIgnoreCase("tinytext")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("text")) {
-						this.columnSize = 65535;
-					} else if (typeInfo.equalsIgnoreCase("mediumtext")) {
-						this.columnSize = 16277215;
-					} else if (typeInfo.equalsIgnoreCase("longtext")) {
-						this.columnSize = Integer.MAX_VALUE;
-					} else if (typeInfo.equalsIgnoreCase("enum")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("set")) {
-						this.columnSize = 255;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "tinyint")) {
+						this.columnSize = new Integer(3);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "smallint")) {
+						this.columnSize = new Integer(5);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "mediumint")) {
+						this.columnSize = new Integer(7);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "int")) {
+						this.columnSize = new Integer(10);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "integer")) {
+						this.columnSize = new Integer(10);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "bigint")) {
+						this.columnSize = new Integer(19);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "int24")) {
+						this.columnSize = new Integer(19);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "real")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "float")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "decimal")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "numeric")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "double")) {
+						this.columnSize = new Integer(22);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "char")) {
+						this.columnSize = new Integer(1);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "varchar")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "date")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "time")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "timestamp")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "datetime")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "tinyblob")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "blob")) {
+						this.columnSize = new Integer(65535);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "mediumblob")) {
+						this.columnSize = new Integer(16777215);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "longblob")) {
+						this.columnSize = new Integer(Integer.MAX_VALUE);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "tinytext")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "text")) {
+						this.columnSize = new Integer(65535);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "mediumtext")) {
+						this.columnSize = new Integer(16777215);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "longtext")) {
+						this.columnSize = new Integer(Integer.MAX_VALUE);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "enum")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "set")) {
+						this.columnSize = new Integer(255);
 					}
 
-					this.decimalDigits = 0;
 				}
 			} else {
-				this.decimalDigits = 0;
-				this.columnSize = 0;
+				this.decimalDigits = null;
+				this.columnSize = null;
 			}
 
 			// BUFFER_LENGTH
@@ -588,9 +599,9 @@
 		}
 		row[5] = s2b(Short.toString(typeDesc.dataType)); // DATA_TYPE
 		row[6] = s2b(typeDesc.typeName); // TYPE_NAME
-		row[7] = s2b(Integer.toString(typeDesc.columnSize)); // PRECISION
+		row[7] = typeDesc.columnSize == null ? null : s2b(typeDesc.columnSize.toString()); // PRECISION
 		row[8] = s2b(Integer.toString(typeDesc.bufferLength)); // LENGTH
-		row[9] = s2b(Integer.toString(typeDesc.decimalDigits)); // SCALE
+		row[9] = typeDesc.decimalDigits == null ? null : s2b(typeDesc.decimalDigits.toString()); // SCALE
 		row[10] = s2b(Integer.toString(typeDesc.numPrecRadix)); // RADIX
 		// Map 'column****' to 'procedure****'
 		switch (typeDesc.nullability) {
@@ -2076,12 +2087,9 @@
 								// DATA_TYPE (jdbc)
 								rowVal[5] = s2b(typeDesc.typeName); // TYPE_NAME
 								// (native)
-								rowVal[6] = s2b(Integer
-										.toString(typeDesc.columnSize));
-								rowVal[7] = s2b(Integer
-										.toString(typeDesc.bufferLength));
-								rowVal[8] = s2b(Integer
-										.toString(typeDesc.decimalDigits));
+								rowVal[6] = typeDesc.columnSize == null ? null : s2b(typeDesc.columnSize.toString());
+								rowVal[7] = s2b(Integer.toString(typeDesc.bufferLength));
+								rowVal[8] = typeDesc.decimalDigits == null ? null : s2b(typeDesc.decimalDigits.toString());
 								rowVal[9] = s2b(Integer
 										.toString(typeDesc.numPrecRadix));
 								rowVal[10] = s2b(Integer
@@ -2110,7 +2118,15 @@
 
 								rowVal[13] = new byte[] { (byte) '0' }; // SQL_DATA_TYPE
 								rowVal[14] = new byte[] { (byte) '0' }; // SQL_DATE_TIME_SUB
-								rowVal[15] = rowVal[6]; // CHAR_OCTET_LENGTH
+								
+								if (StringUtils.indexOfIgnoreCase(typeDesc.typeName, "CHAR") != -1 ||
+										StringUtils.indexOfIgnoreCase(typeDesc.typeName, "BLOB") != -1 ||
+										StringUtils.indexOfIgnoreCase(typeDesc.typeName, "TEXT") != -1 ||
+										StringUtils.indexOfIgnoreCase(typeDesc.typeName, "BINARY") != -1) {
+									rowVal[15] = rowVal[6]; // CHAR_OCTET_LENGTH
+								} else {
+									rowVal[15] = null;
+								}
 
 								// ORDINAL_POSITION
 								if (!fixUpOrdinalsRequired) {

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-12-07 22:06:30 UTC (rev 6132)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java	2006-12-07 22:47:38 UTC (rev 6133)
@@ -97,18 +97,15 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
-			}
-
-			catalog = this.database;
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
+			}	
 		}
 		
 		String sql = "SELECT TABLE_SCHEMA AS TABLE_CAT, NULL AS TABLE_SCHEM, TABLE_NAME,"
 			 +"COLUMN_NAME, NULL AS GRANTOR, GRANTEE, PRIVILEGE_TYPE AS PRIVILEGE, IS_GRANTABLE FROM "
 			 + "INFORMATION_SCHEMA.COLUMN_PRIVILEGES WHERE "
-			 + "TABLE_SCHEMA = ? AND "
+			 + "TABLE_SCHEMA LIKE ? AND "
 			 + "TABLE_NAME =? AND COLUMN_NAME LIKE ? ORDER BY " 
 			 + "COLUMN_NAME, PRIVILEGE_TYPE";
 		
@@ -116,7 +113,13 @@
 		
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 			pStmt.setString(3, columnNamePattern);
 			
@@ -196,12 +199,9 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		StringBuffer sqlBuf = new StringBuffer("SELECT "
@@ -221,26 +221,33 @@
 				.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,"
+						+ MysqlIO.getMaxBuf() + " AS BUFFER_LENGTH,"
 						+ "NUMERIC_SCALE AS DECIMAL_DIGITS,"
 						+ "10 AS NUM_PREC_RADIX,"
-						+ "NULL AS NULLABLE,"
+						+ "CASE WHEN IS_NULLABLE='NO' THEN " + columnNoNulls + " ELSE CASE WHEN IS_NULLABLE='YES' THEN " + columnNullable + " ELSE " + columnNullableUnknown + " END END 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,"
+						+ "0 AS SQL_DATA_TYPE,"
+						+ "0 AS SQL_DATETIME_SUB,"
+						+ "CASE WHEN CHARACTER_OCTET_LENGTH > " + Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + " ELSE CHARACTER_OCTET_LENGTH END AS CHAR_OCTET_LENGTH,"
 						+ "ORDINAL_POSITION,"
 						+ "IS_NULLABLE "
 						+ "FROM INFORMATION_SCHEMA.COLUMNS WHERE "
-						+ "TABLE_SCHEMA LIKE ? AND TABLE_NAME LIKE ? AND COLUMN_NAME LIKE ? "
+						+ "TABLE_SCHEMA LIKE ? AND "
+						+ "TABLE_NAME LIKE ? AND COLUMN_NAME LIKE ? "
 						+ "ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION");
 
 		PreparedStatement pStmt = null;
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, tableName);
 			pStmt.setString(3, columnNamePattern);
 
@@ -352,21 +359,15 @@
 		}
 
 		if (primaryCatalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				primaryCatalog = this.database;	
 			}
-
-			primaryCatalog = this.database;
 		}
 
 		if (foreignCatalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				foreignCatalog = this.database;
 			}
-
-			foreignCatalog = this.database;
 		}
 
 		Field[] fields = new Field[14];
@@ -410,17 +411,28 @@
 				+ "A.TABLE_SCHEMA=B.TABLE_SCHEMA AND A.TABLE_NAME=B.TABLE_NAME "
 				+ "AND "
 				+ "A.CONSTRAINT_NAME=B.CONSTRAINT_NAME AND B.CONSTRAINT_TYPE IS NOT NULL "
-				+ "AND A.REFERENCED_TABLE_SCHEMA=? AND A.REFERENCED_TABLE_NAME=? "
-				+ "AND A.TABLE_SCHEMA=? AND A.TABLE_NAME=? " + "ORDER BY "
+				+ "AND A.REFERENCED_TABLE_SCHEMA LIKE ? AND A.REFERENCED_TABLE_NAME=? "
+				+ "AND A.TABLE_SCHEMA LIKE ? AND A.TABLE_NAME=? " + "ORDER BY "
 				+ "A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION";
 
 		PreparedStatement pStmt = null;
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, primaryCatalog);
+			if (primaryCatalog != null) {
+				pStmt.setString(1, primaryCatalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, primaryTable);
-			pStmt.setString(3, foreignCatalog);
+			
+			if (foreignCatalog != null) {
+				pStmt.setString(3, foreignCatalog);
+			} else {
+				pStmt.setString(3, "%");
+			}
+			
 			pStmt.setString(4, foreignTable);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -517,12 +529,9 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
-			}
-
-			catalog = this.database;
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
+			}	
 		}
 
 		String sql = "SELECT "
@@ -550,14 +559,20 @@
 				+ "A.TABLE_SCHEMA=B.TABLE_SCHEMA AND A.TABLE_NAME=B.TABLE_NAME "
 				+ "AND "
 				+ "A.CONSTRAINT_NAME=B.CONSTRAINT_NAME AND B.CONSTRAINT_TYPE IS NOT NULL "
-				+ "AND A.REFERENCED_TABLE_SCHEMA=? AND A.REFERENCED_TABLE_NAME=? "
+				+ "AND A.REFERENCED_TABLE_SCHEMA LIKE ? AND A.REFERENCED_TABLE_NAME=? "
 				+ "ORDER BY A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION";
 
 		PreparedStatement pStmt = null;
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -680,12 +695,9 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		String sql = "SELECT "
@@ -708,7 +720,7 @@
 				+ " AS DEFERRABILITY "
 				+ "FROM "
 				+ "INFORMATION_SCHEMA.KEY_COLUMN_USAGE A, "
-				+ "INFORMATION_SCHEMA.TABLE_CONSTRAINTS B WHERE A.TABLE_SCHEMA=? "
+				+ "INFORMATION_SCHEMA.TABLE_CONSTRAINTS B WHERE A.TABLE_SCHEMA LIKE ? "
 				+ "AND A.CONSTRAINT_NAME=B.CONSTRAINT_NAME AND A.TABLE_NAME=? "
 				+ "AND "
 				+ "B.TABLE_NAME=? AND A.REFERENCED_TABLE_SCHEMA IS NOT NULL "
@@ -720,7 +732,13 @@
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 			pStmt.setString(3, table);
 
@@ -830,9 +848,20 @@
 		PreparedStatement pStmt = null;
 
 		try {
+			if (catalog == null) {
+				if (this.conn.getNullCatalogMeansCurrent()) {
+					catalog = this.database;
+				}
+			}
+			
 			pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
 
-			pStmt.setString(1, catalog);
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -889,12 +918,9 @@
 			String table) throws SQLException {
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		if (table == null) {
@@ -912,7 +938,12 @@
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
 
-			pStmt.setString(1, catalog);
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -989,17 +1020,9 @@
 		String db = null;
 
 		if (catalog == null) {
-			db = this.database;
-		} else if (catalog.length() > 0) {
-			db = catalog;
-		} else {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				db = this.database;
 			}
-
-			catalog = null;
-			db = null;
 		}
 
 		String sql = "SELECT ROUTINE_SCHEMA AS PROCEDURE_CAT, "
@@ -1019,7 +1042,13 @@
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, db);
+			
+			if (db != null) {
+				pStmt.setString(1, db);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, procedureNamePattern);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -1080,12 +1109,9 @@
 	public ResultSet getTables(String catalog, String schemaPattern,
 			String tableNamePattern, String[] types) throws SQLException {
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		if (tableNamePattern == null) {
@@ -1109,7 +1135,13 @@
 				+ "ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME";
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, tableNamePattern);
 
 			// This overloading of IN (...) allows us to cache this

Modified: branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-12-07 22:06:30 UTC (rev 6132)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-12-07 22:47:38 UTC (rev 6133)
@@ -1689,4 +1689,152 @@
 		this.conn.getMetaData().getProcedures(bogusDatabaseName, "%", "%");
 	}
 
+	/**
+	 * Tests fix for BUG#23304 - DBMD using "show" and DBMD using 
+	 * information_schema do not return results consistent with eachother.
+	 * 
+	 * (note this fix only addresses the inconsistencies, not the issue that
+	 * the driver is treating schemas differently than some users expect.
+	 * 
+	 * We will revisit this behavior when there is full support for schemas
+	 * in MySQL).
+	 * 
+	 * @throws Exception
+	 */
+	
+	public void testBug23304() throws Exception {
+		if (!versionMeetsMinimum(5, 0)) {
+			return;
+		}
+		
+		Connection connShow = null;
+		Connection connInfoSchema = null;
+		
+		ResultSet rsShow = null;
+		ResultSet rsInfoSchema = null;
+		
+		try {
+			Properties noInfoSchemaProps = new Properties();
+			noInfoSchemaProps.setProperty("useInformationSchema", "false");
+			
+			Properties infoSchemaProps = new Properties();
+			infoSchemaProps.setProperty("useInformationSchema", "true");
+			infoSchemaProps.setProperty("dumpQueriesOnException", "true");
+			
+			connShow = getConnectionWithProps(noInfoSchemaProps);
+			connInfoSchema = getConnectionWithProps(infoSchemaProps);
+			
+			DatabaseMetaData dbmdUsingShow = connShow.getMetaData();
+			DatabaseMetaData dbmdUsingInfoSchema = connInfoSchema.getMetaData();
+			
+			assertNotSame(dbmdUsingShow.getClass(), dbmdUsingInfoSchema.getClass());
+			
+			if (!isRunningOnJdk131()) {
+				rsShow = dbmdUsingShow.getSchemas();
+				rsInfoSchema = dbmdUsingInfoSchema.getSchemas();
+			
+				compareResultSets(rsShow, rsInfoSchema);	
+			}
+			
+			/*
+			rsShow = dbmdUsingShow.getTables(connShow.getCatalog(), null, "%", new String[] {"TABLE", "VIEW"});
+			rsInfoSchema = dbmdUsingInfoSchema.getTables(connInfoSchema.getCatalog(), null, "%", new String[] {"TABLE", "VIEW"});
+			
+			compareResultSets(rsShow, rsInfoSchema);
+			
+			rsShow = dbmdUsingShow.getTables(null, null, "%", new String[] {"TABLE", "VIEW"});
+			rsInfoSchema = dbmdUsingInfoSchema.getTables(null, null, "%", new String[] {"TABLE", "VIEW"});
+		
+			compareResultSets(rsShow, rsInfoSchema);
+			*/
+			
+			createTable("t_testBug23304", "(field1 int primary key not null, field2 tinyint, field3 mediumint, field4 mediumint, field5 bigint, field6 float, field7 double, field8 decimal, field9 char(32), field10 varchar(32), field11 blob, field12 mediumblob, field13 longblob, field14 text, field15 mediumtext, field16 longtext, field17 date, field18 time, field19 datetime, field20 timestamp)");
+			
+			rsShow = dbmdUsingShow.getColumns(connShow.getCatalog(), null, "t_testBug23304", "%");
+			rsInfoSchema = dbmdUsingInfoSchema.getColumns(connInfoSchema.getCatalog(), null, "t_testBug23304", "%");
+			
+			compareResultSets(rsShow, rsInfoSchema);
+		} finally {
+			if (rsShow != null) {
+				rsShow.close();
+			}
+			
+			if (rsInfoSchema != null) {
+				rsInfoSchema.close();
+			}
+		}
+	}
+	
+	private void compareResultSets(ResultSet expected, ResultSet actual) throws Exception {
+		if (expected == null && actual != null) {
+			fail("Expected null result set, actual was not null.");
+		} else if (expected != null && actual == null) {
+			fail("Expected non-null actual result set.");
+		} else if (expected == null && actual == null) {
+			return;
+		}
+		
+		expected.last();
+		
+		int expectedRows = expected.getRow();
+		
+		actual.last();
+		
+		int actualRows = actual.getRow();
+		
+		assertEquals(expectedRows, actualRows);
+		
+		ResultSetMetaData metadataExpected = expected.getMetaData();
+		ResultSetMetaData metadataActual = actual.getMetaData();
+		
+		assertEquals(metadataExpected.getColumnCount(), metadataActual.getColumnCount());
+		
+		for (int i = 0; i < metadataExpected.getColumnCount(); i++) {
+			assertEquals(metadataExpected.getColumnName(i + 1), metadataActual.getColumnName(i + 1));
+			assertEquals(metadataExpected.getColumnType(i + 1), metadataActual.getColumnType(i + 1));
+			assertEquals(metadataExpected.getColumnClassName(i + 1), metadataActual.getColumnClassName(i + 1));
+		}
+		
+		expected.beforeFirst();
+		actual.beforeFirst();
+		
+		StringBuffer messageBuf = null;
+		
+		while (expected.next() && actual.next()) {
+			
+			if (messageBuf != null) {
+				messageBuf.append("\n");
+			}
+			
+			for (int i = 0; i < metadataExpected.getColumnCount(); i++) {
+				if (expected.getObject(i + 1) == null && actual.getObject(i + 1) == null) {
+					continue;
+				}
+				
+				if ((expected.getObject(i + 1) == null && actual.getObject(i + 1) != null) ||
+						(expected.getObject(i + 1) != null && actual.getObject(i + 1) == null) ||
+						(!expected.getObject(i + 1).equals(actual.getObject(i + 1)))) {
+					if ("COLUMN_DEF".equals(metadataExpected.getColumnName(i + 1)) && 
+							(expected.getObject(i + 1) == null && actual.getString(i + 1).length() == 0) ||
+							(expected.getString(i + 1).length() == 0 && actual.getObject(i + 1) == null)) {
+						continue; // known bug with SHOW FULL COLUMNS, and we can't distinguish between null and ''
+						          // for a default
+					}
+					
+					if (messageBuf == null) {
+						messageBuf = new StringBuffer();
+					} else {
+						messageBuf.append("\n");
+					}
+					
+					messageBuf.append("On row " + expected.getRow() + " ,for column named " + metadataExpected.getColumnName(i + 1) + ", expected '" + expected.getObject(i + 1) + "', found '" + actual.getObject(i + 1) + "'");
+					
+				}
+			}
+		}
+		
+		if (messageBuf != null) {
+			fail(messageBuf.toString());
+		}
+	}
 }

Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES	2006-12-07 22:06:30 UTC (rev 6132)
+++ trunk/connector-j/CHANGES	2006-12-07 22:47:38 UTC (rev 6133)
@@ -21,7 +21,13 @@
 	  true", as the driver can't tell if this is a new deployment that never used 
 	  server-side prepared statements, or if it is an existing deployment that is
 	  switching to client-side prepared statements from server-side prepared statements.
-	   
+
+    - Fixed BUG#23304 - DBMD using "show" and DBMD using information_schema do 
+      not return results consistent with each other. (note this fix only 
+      addresses the inconsistencies, not the issue that the driver is 
+      treating schemas differently than some users expect. We will revisit 
+      this behavior when there is full support for schemas in MySQL).
+	  	   
 10-20-06 - Version 5.0.4
 
     - Fixed BUG#21379 - column names don't match metadata in cases 

Modified: trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java	2006-12-07 22:06:30 UTC (rev 6132)
+++ trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java	2006-12-07 22:47:38 UTC (rev 6133)
@@ -171,11 +171,11 @@
 
 		int charOctetLength;
 
-		int columnSize;
+		Integer columnSize;
 
 		short dataType;
 
-		int decimalDigits;
+		Integer decimalDigits;
 
 		String isNullable;
 
@@ -235,8 +235,8 @@
 								.length() - 2));
 					}
 
-					this.columnSize = maxLength;
-					this.decimalDigits = 0;
+					this.columnSize = new Integer(maxLength);
+					this.decimalDigits = null;
 				} else if (StringUtils.startsWithIgnoreCase(typeInfo, "set")) {
 					String temp = typeInfo.substring(typeInfo.indexOf("("),
 							typeInfo.lastIndexOf(")"));
@@ -254,33 +254,38 @@
 						}
 					}
 
-					this.columnSize = maxLength;
-					this.decimalDigits = 0;
+					this.columnSize = new Integer(maxLength);
+					this.decimalDigits = null;
 				} else if (typeInfo.indexOf(",") != -1) {
 					// Numeric with decimals
-					this.columnSize = Integer.parseInt(typeInfo.substring(
+					this.columnSize = new Integer(typeInfo.substring(
 							(typeInfo.indexOf("(") + 1),
 							(typeInfo.indexOf(","))));
-					this.decimalDigits = Integer.parseInt(typeInfo.substring(
+					this.decimalDigits = new Integer(typeInfo.substring(
 							(typeInfo.indexOf(",") + 1),
 							(typeInfo.indexOf(")"))));
 				} else {
-					this.columnSize = 0;
-
+					this.columnSize = null;
+					this.decimalDigits = null;
+					
 					/* If the size is specified with the DDL, use that */
-					if (typeInfo.indexOf("(") != -1) {
+					if ((StringUtils.indexOfIgnoreCase(typeInfo, "char") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "text") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "blob") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "binary") != -1 ||
+							StringUtils.indexOfIgnoreCase(typeInfo, "bit") != -1) && typeInfo.indexOf("(") != -1) {
 						int endParenIndex = typeInfo.indexOf(")");
 
 						if (endParenIndex == -1) {
 							endParenIndex = typeInfo.length();
 						}
 
-						this.columnSize = Integer.parseInt(typeInfo.substring(
+						this.columnSize = new Integer(typeInfo.substring(
 								(typeInfo.indexOf("(") + 1), endParenIndex));
 
 						// Adjust for pseudo-boolean
 						if (conn.getTinyInt1isBit()
-								&& this.columnSize == 1
+								&& this.columnSize.intValue() == 1
 								&& StringUtils.startsWithIgnoreCase(typeInfo,
 										0, "tinyint")) {
 							if (conn.getTransformedBitIsBoolean()) {
@@ -291,69 +296,75 @@
 								this.typeName = "BIT";
 							}
 						}
-					} else if (typeInfo.equalsIgnoreCase("tinyint")) {
-						this.columnSize = 1;
-					} else if (typeInfo.equalsIgnoreCase("smallint")) {
-						this.columnSize = 6;
-					} else if (typeInfo.equalsIgnoreCase("mediumint")) {
-						this.columnSize = 6;
-					} else if (typeInfo.equalsIgnoreCase("int")) {
-						this.columnSize = 11;
-					} else if (typeInfo.equalsIgnoreCase("integer")) {
-						this.columnSize = 11;
-					} else if (typeInfo.equalsIgnoreCase("bigint")) {
-						this.columnSize = 25;
-					} else if (typeInfo.equalsIgnoreCase("int24")) {
-						this.columnSize = 25;
-					} else if (typeInfo.equalsIgnoreCase("real")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("float")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("decimal")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("numeric")) {
-						this.columnSize = 12;
-					} else if (typeInfo.equalsIgnoreCase("double")) {
-						this.columnSize = 22;
-					} else if (typeInfo.equalsIgnoreCase("char")) {
-						this.columnSize = 1;
-					} else if (typeInfo.equalsIgnoreCase("varchar")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("date")) {
-						this.columnSize = 10;
-					} else if (typeInfo.equalsIgnoreCase("time")) {
-						this.columnSize = 8;
-					} else if (typeInfo.equalsIgnoreCase("timestamp")) {
-						this.columnSize = 19;
-					} else if (typeInfo.equalsIgnoreCase("datetime")) {
-						this.columnSize = 19;
-					} else if (typeInfo.equalsIgnoreCase("tinyblob")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("blob")) {
-						this.columnSize = 65535;
-					} else if (typeInfo.equalsIgnoreCase("mediumblob")) {
-						this.columnSize = 16277215;
-					} else if (typeInfo.equalsIgnoreCase("longblob")) {
-						this.columnSize = Integer.MAX_VALUE;
-					} else if (typeInfo.equalsIgnoreCase("tinytext")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("text")) {
-						this.columnSize = 65535;
-					} else if (typeInfo.equalsIgnoreCase("mediumtext")) {
-						this.columnSize = 16277215;
-					} else if (typeInfo.equalsIgnoreCase("longtext")) {
-						this.columnSize = Integer.MAX_VALUE;
-					} else if (typeInfo.equalsIgnoreCase("enum")) {
-						this.columnSize = 255;
-					} else if (typeInfo.equalsIgnoreCase("set")) {
-						this.columnSize = 255;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "tinyint")) {
+						this.columnSize = new Integer(3);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "smallint")) {
+						this.columnSize = new Integer(5);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "mediumint")) {
+						this.columnSize = new Integer(7);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "int")) {
+						this.columnSize = new Integer(10);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "integer")) {
+						this.columnSize = new Integer(10);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "bigint")) {
+						this.columnSize = new Integer(19);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "int24")) {
+						this.columnSize = new Integer(19);
+						this.decimalDigits = new Integer(0);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "real")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "float")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "decimal")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "numeric")) {
+						this.columnSize = new Integer(12);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "double")) {
+						this.columnSize = new Integer(22);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "char")) {
+						this.columnSize = new Integer(1);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "varchar")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "date")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "time")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "timestamp")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "datetime")) {
+						this.columnSize = null;
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "tinyblob")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "blob")) {
+						this.columnSize = new Integer(65535);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "mediumblob")) {
+						this.columnSize = new Integer(16777215);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "longblob")) {
+						this.columnSize = new Integer(Integer.MAX_VALUE);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "tinytext")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "text")) {
+						this.columnSize = new Integer(65535);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "mediumtext")) {
+						this.columnSize = new Integer(16777215);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "longtext")) {
+						this.columnSize = new Integer(Integer.MAX_VALUE);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "enum")) {
+						this.columnSize = new Integer(255);
+					} else if (StringUtils.startsWithIgnoreCaseAndWs(typeInfo, "set")) {
+						this.columnSize = new Integer(255);
 					}
 
-					this.decimalDigits = 0;
 				}
 			} else {
-				this.decimalDigits = 0;
-				this.columnSize = 0;
+				this.decimalDigits = null;
+				this.columnSize = null;
 			}
 
 			// BUFFER_LENGTH
@@ -545,7 +556,6 @@
 			}
 		}
 	}
-
 	private void convertToJdbcProcedureList(boolean fromSelect, String catalog,
 			ResultSet proceduresRs, boolean needsClientFiltering, String db,
 			Map procedureRowsOrderedByName, int nameIndex) throws SQLException {
@@ -567,13 +577,13 @@
 			if (shouldAdd) {
 				String procedureName = proceduresRs.getString(nameIndex);
 				byte[][] rowData = new byte[8][];
-				rowData[0] = catalog == null ? null : s2b(catalog);  // PROCEDURE_CAT
-				rowData[1] = null;                                   // PROCEDURE_SCHEM
-				rowData[2] = s2b(procedureName);                     // PROCEDURE_NAME
-				rowData[3] = null;                                   // reserved1
-				rowData[4] = null;                                   // reserved2
-				rowData[5] = null;                                   // reserved3
-				rowData[6] = s2b(proceduresRs.getString("comment")); // REMARKS
+				rowData[0] = catalog == null ? null : s2b(catalog);
+				rowData[1] = null;
+				rowData[2] = s2b(procedureName);
+				rowData[3] = null;
+				rowData[4] = null;
+				rowData[5] = null;
+				rowData[6] = null;
 
 				boolean isFunction = fromSelect ? "FUNCTION"
 						.equalsIgnoreCase(proceduresRs.getString("type"))
@@ -610,9 +620,9 @@
 		}
 		row[5] = s2b(Short.toString(typeDesc.dataType)); // DATA_TYPE
 		row[6] = s2b(typeDesc.typeName); // TYPE_NAME
-		row[7] = s2b(Integer.toString(typeDesc.columnSize)); // PRECISION
+		row[7] = typeDesc.columnSize == null ? null : s2b(typeDesc.columnSize.toString()); // PRECISION
 		row[8] = s2b(Integer.toString(typeDesc.bufferLength)); // LENGTH
-		row[9] = s2b(Integer.toString(typeDesc.decimalDigits)); // SCALE
+		row[9] = typeDesc.decimalDigits == null ? null : s2b(typeDesc.decimalDigits.toString()); // SCALE
 		row[10] = s2b(Integer.toString(typeDesc.numPrecRadix)); // RADIX
 		// Map 'column****' to 'procedure****'
 		switch (typeDesc.nullability) {
@@ -1216,8 +1226,6 @@
 		// First try 'select from mysql.proc, as this is easier to parse...
 		String parameterDef = null;
 		
-		PreparedStatement paramRetrievalPreparedStatement = null;
-		
 		try {
 			paramRetrievalStmt = this.conn.getMetadataSafeStatement();
 			
@@ -1417,16 +1425,6 @@
 				paramRetrievalRs = null;
 			}
 
-			if (paramRetrievalPreparedStatement != null) {
-				try {
-					paramRetrievalPreparedStatement.close();
-				} catch (SQLException sqlEx) {
-					sqlExRethrow = sqlEx;
-				}
-
-				paramRetrievalPreparedStatement = null;
-			}
-
 			if (paramRetrievalStmt != null) {
 				try {
 					paramRetrievalStmt.close();
@@ -2110,12 +2108,9 @@
 								// DATA_TYPE (jdbc)
 								rowVal[5] = s2b(typeDesc.typeName); // TYPE_NAME
 								// (native)
-								rowVal[6] = s2b(Integer
-										.toString(typeDesc.columnSize));
-								rowVal[7] = s2b(Integer
-										.toString(typeDesc.bufferLength));
-								rowVal[8] = s2b(Integer
-										.toString(typeDesc.decimalDigits));
+								rowVal[6] = typeDesc.columnSize == null ? null : s2b(typeDesc.columnSize.toString());
+								rowVal[7] = s2b(Integer.toString(typeDesc.bufferLength));
+								rowVal[8] = typeDesc.decimalDigits == null ? null : s2b(typeDesc.decimalDigits.toString());
 								rowVal[9] = s2b(Integer
 										.toString(typeDesc.numPrecRadix));
 								rowVal[10] = s2b(Integer
@@ -2144,7 +2139,15 @@
 
 								rowVal[13] = new byte[] { (byte) '0' }; // SQL_DATA_TYPE
 								rowVal[14] = new byte[] { (byte) '0' }; // SQL_DATE_TIME_SUB
-								rowVal[15] = rowVal[6]; // CHAR_OCTET_LENGTH
+								
+								if (StringUtils.indexOfIgnoreCase(typeDesc.typeName, "CHAR") != -1 ||
+										StringUtils.indexOfIgnoreCase(typeDesc.typeName, "BLOB") != -1 ||
+										StringUtils.indexOfIgnoreCase(typeDesc.typeName, "TEXT") != -1 ||
+										StringUtils.indexOfIgnoreCase(typeDesc.typeName, "BINARY") != -1) {
+									rowVal[15] = rowVal[6]; // CHAR_OCTET_LENGTH
+								} else {
+									rowVal[15] = null;
+								}
 
 								// ORDINAL_POSITION
 								if (!fixUpOrdinalsRequired) {
@@ -3660,7 +3663,7 @@
 					&& (procedureNamePattern.indexOf("?") == -1)) {
 				proceduresToExtractList.add(procedureNamePattern);
 			} else {
-				PreparedStatement procedureNameStmt = null;
+				
 				ResultSet procedureNameRs = null;
 
 				try {
@@ -3688,15 +3691,7 @@
 							rethrowSqlEx = sqlEx;
 						}
 					}
-
-					if (procedureNameStmt != null) {
-						try {
-							procedureNameStmt.close();
-						} catch (SQLException sqlEx) {
-							rethrowSqlEx = sqlEx;
-						}
-					}
-
+					
 					if (rethrowSqlEx != null) {
 						throw rethrowSqlEx;
 					}
@@ -3933,6 +3928,7 @@
 		return buildResultSet(fields, procedureRows);
 	}
 
+
 	/**
 	 * What's the database vendor's preferred term for "procedure"?
 	 * 
@@ -7526,10 +7522,6 @@
 		throw new JDBC40NotYetImplementedException();
 	}
 
-	public boolean providesQueryObjectGenerator() throws SQLException {
-		return false; // we don't - rely on the built-in JDK one
-	}
-
 	public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
 		return true;
 	}
@@ -7545,4 +7537,9 @@
 	public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException {
 		throw new JDBC40NotYetImplementedException();
 	}
+
+	public boolean providesQueryObjectGenerator() throws SQLException {
+		// TODO Auto-generated method stub
+		return false;
+	}
 }

Modified: trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java	2006-12-07 22:06:30 UTC (rev 6132)
+++ trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java	2006-12-07 22:47:38 UTC (rev 6133)
@@ -97,18 +97,15 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
-			}
-
-			catalog = this.database;
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
+			}	
 		}
 		
 		String sql = "SELECT TABLE_SCHEMA AS TABLE_CAT, NULL AS TABLE_SCHEM, TABLE_NAME,"
 			 +"COLUMN_NAME, NULL AS GRANTOR, GRANTEE, PRIVILEGE_TYPE AS PRIVILEGE, IS_GRANTABLE FROM "
 			 + "INFORMATION_SCHEMA.COLUMN_PRIVILEGES WHERE "
-			 + "TABLE_SCHEMA = ? AND "
+			 + "TABLE_SCHEMA LIKE ? AND "
 			 + "TABLE_NAME =? AND COLUMN_NAME LIKE ? ORDER BY " 
 			 + "COLUMN_NAME, PRIVILEGE_TYPE";
 		
@@ -116,7 +113,13 @@
 		
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 			pStmt.setString(3, columnNamePattern);
 			
@@ -196,12 +199,9 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		StringBuffer sqlBuf = new StringBuffer("SELECT "
@@ -221,26 +221,33 @@
 				.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,"
+						+ MysqlIO.getMaxBuf() + " AS BUFFER_LENGTH,"
 						+ "NUMERIC_SCALE AS DECIMAL_DIGITS,"
 						+ "10 AS NUM_PREC_RADIX,"
-						+ "NULL AS NULLABLE,"
+						+ "CASE WHEN IS_NULLABLE='NO' THEN " + columnNoNulls + " ELSE CASE WHEN IS_NULLABLE='YES' THEN " + columnNullable + " ELSE " + columnNullableUnknown + " END END 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,"
+						+ "0 AS SQL_DATA_TYPE,"
+						+ "0 AS SQL_DATETIME_SUB,"
+						+ "CASE WHEN CHARACTER_OCTET_LENGTH > " + Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + " ELSE CHARACTER_OCTET_LENGTH END AS CHAR_OCTET_LENGTH,"
 						+ "ORDINAL_POSITION,"
 						+ "IS_NULLABLE "
 						+ "FROM INFORMATION_SCHEMA.COLUMNS WHERE "
-						+ "TABLE_SCHEMA LIKE ? AND TABLE_NAME LIKE ? AND COLUMN_NAME LIKE ? "
+						+ "TABLE_SCHEMA LIKE ? AND "
+						+ "TABLE_NAME LIKE ? AND COLUMN_NAME LIKE ? "
 						+ "ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION");
 
 		PreparedStatement pStmt = null;
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, tableName);
 			pStmt.setString(3, columnNamePattern);
 
@@ -352,21 +359,15 @@
 		}
 
 		if (primaryCatalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				primaryCatalog = this.database;	
 			}
-
-			primaryCatalog = this.database;
 		}
 
 		if (foreignCatalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				foreignCatalog = this.database;
 			}
-
-			foreignCatalog = this.database;
 		}
 
 		Field[] fields = new Field[14];
@@ -410,17 +411,28 @@
 				+ "A.TABLE_SCHEMA=B.TABLE_SCHEMA AND A.TABLE_NAME=B.TABLE_NAME "
 				+ "AND "
 				+ "A.CONSTRAINT_NAME=B.CONSTRAINT_NAME AND B.CONSTRAINT_TYPE IS NOT NULL "
-				+ "AND A.REFERENCED_TABLE_SCHEMA=? AND A.REFERENCED_TABLE_NAME=? "
-				+ "AND A.TABLE_SCHEMA=? AND A.TABLE_NAME=? " + "ORDER BY "
+				+ "AND A.REFERENCED_TABLE_SCHEMA LIKE ? AND A.REFERENCED_TABLE_NAME=? "
+				+ "AND A.TABLE_SCHEMA LIKE ? AND A.TABLE_NAME=? " + "ORDER BY "
 				+ "A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION";
 
 		PreparedStatement pStmt = null;
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, primaryCatalog);
+			if (primaryCatalog != null) {
+				pStmt.setString(1, primaryCatalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, primaryTable);
-			pStmt.setString(3, foreignCatalog);
+			
+			if (foreignCatalog != null) {
+				pStmt.setString(3, foreignCatalog);
+			} else {
+				pStmt.setString(3, "%");
+			}
+			
 			pStmt.setString(4, foreignTable);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -517,12 +529,9 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
-			}
-
-			catalog = this.database;
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
+			}	
 		}
 
 		String sql = "SELECT "
@@ -550,14 +559,20 @@
 				+ "A.TABLE_SCHEMA=B.TABLE_SCHEMA AND A.TABLE_NAME=B.TABLE_NAME "
 				+ "AND "
 				+ "A.CONSTRAINT_NAME=B.CONSTRAINT_NAME AND B.CONSTRAINT_TYPE IS NOT NULL "
-				+ "AND A.REFERENCED_TABLE_SCHEMA=? AND A.REFERENCED_TABLE_NAME=? "
+				+ "AND A.REFERENCED_TABLE_SCHEMA LIKE ? AND A.REFERENCED_TABLE_NAME=? "
 				+ "ORDER BY A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION";
 
 		PreparedStatement pStmt = null;
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -680,12 +695,9 @@
 		}
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		String sql = "SELECT "
@@ -708,7 +720,7 @@
 				+ " AS DEFERRABILITY "
 				+ "FROM "
 				+ "INFORMATION_SCHEMA.KEY_COLUMN_USAGE A, "
-				+ "INFORMATION_SCHEMA.TABLE_CONSTRAINTS B WHERE A.TABLE_SCHEMA=? "
+				+ "INFORMATION_SCHEMA.TABLE_CONSTRAINTS B WHERE A.TABLE_SCHEMA LIKE ? "
 				+ "AND A.CONSTRAINT_NAME=B.CONSTRAINT_NAME AND A.TABLE_NAME=? "
 				+ "AND "
 				+ "B.TABLE_NAME=? AND A.REFERENCED_TABLE_SCHEMA IS NOT NULL "
@@ -720,7 +732,13 @@
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 			pStmt.setString(3, table);
 
@@ -830,9 +848,20 @@
 		PreparedStatement pStmt = null;
 
 		try {
+			if (catalog == null) {
+				if (this.conn.getNullCatalogMeansCurrent()) {
+					catalog = this.database;
+				}
+			}
+			
 			pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
 
-			pStmt.setString(1, catalog);
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -889,12 +918,9 @@
 			String table) throws SQLException {
 
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		if (table == null) {
@@ -912,7 +938,12 @@
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
 
-			pStmt.setString(1, catalog);
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, table);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -989,17 +1020,9 @@
 		String db = null;
 
 		if (catalog == null) {
-			db = this.database;
-		} else if (catalog.length() > 0) {
-			db = catalog;
-		} else {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				db = this.database;
 			}
-
-			catalog = null;
-			db = null;
 		}
 
 		String sql = "SELECT ROUTINE_SCHEMA AS PROCEDURE_CAT, "
@@ -1019,7 +1042,13 @@
 
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, db);
+			
+			if (db != null) {
+				pStmt.setString(1, db);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, procedureNamePattern);
 
 			ResultSet rs = executeMetadataQuery(pStmt);
@@ -1080,12 +1109,9 @@
 	public ResultSet getTables(String catalog, String schemaPattern,
 			String tableNamePattern, String[] types) throws SQLException {
 		if (catalog == null) {
-			if (!this.conn.getNullCatalogMeansCurrent()) {
-				throw SQLError.createSQLException("'catalog' parameter can not be null",
-						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
+			if (this.conn.getNullCatalogMeansCurrent()) {
+				catalog = this.database;
 			}
-
-			catalog = this.database;
 		}
 
 		if (tableNamePattern == null) {
@@ -1109,7 +1135,13 @@
 				+ "ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME";
 		try {
 			pStmt = prepareMetaDataSafeStatement(sql);
-			pStmt.setString(1, catalog);
+			
+			if (catalog != null) {
+				pStmt.setString(1, catalog);
+			} else {
+				pStmt.setString(1, "%");
+			}
+			
 			pStmt.setString(2, tableNamePattern);
 
 			// This overloading of IN (...) allows us to cache this

Modified: trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-12-07 22:06:30 UTC (rev 6132)
+++ trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java	2006-12-07 22:47:38 UTC (rev 6133)
@@ -1678,4 +1678,151 @@
 		this.conn.getMetaData().getProcedures(bogusDatabaseName, "%", "%");
 	}
 
+	/**
+	 * Tests fix for BUG#23304 - DBMD using "show" and DBMD using 
+	 * information_schema do not return results consistent with eachother.
+	 * 
+	 * (note this fix only addresses the inconsistencies, not the issue that
+	 * the driver is treating schemas differently than some users expect.
+	 * 
+	 * We will revisit this behavior when there is full support for schemas
+	 * in MySQL).
+	 * 
+	 * @throws Exception
+	 */
+	public void testBug23304() throws Exception {
+		if (!versionMeetsMinimum(5, 0)) {
+			return;
+		}
+		
+		Connection connShow = null;
+		Connection connInfoSchema = null;
+		
+		ResultSet rsShow = null;
+		ResultSet rsInfoSchema = null;
+		
+		try {
+			Properties noInfoSchemaProps = new Properties();
+			noInfoSchemaProps.setProperty("useInformationSchema", "false");
+			
+			Properties infoSchemaProps = new Properties();
+			infoSchemaProps.setProperty("useInformationSchema", "true");
+			infoSchemaProps.setProperty("dumpQueriesOnException", "true");
+			
+			connShow = getConnectionWithProps(noInfoSchemaProps);
+			connInfoSchema = getConnectionWithProps(infoSchemaProps);
+			
+			DatabaseMetaData dbmdUsingShow = connShow.getMetaData();
+			DatabaseMetaData dbmdUsingInfoSchema = connInfoSchema.getMetaData();
+			
+			assertNotSame(dbmdUsingShow.getClass(), dbmdUsingInfoSchema.getClass());
+			
+			if (!isRunningOnJdk131()) {
+				rsShow = dbmdUsingShow.getSchemas();
+				rsInfoSchema = dbmdUsingInfoSchema.getSchemas();
+			
+				compareResultSets(rsShow, rsInfoSchema);	
+			}
+			
+			/*
+			rsShow = dbmdUsingShow.getTables(connShow.getCatalog(), null, "%", new String[] {"TABLE", "VIEW"});
+			rsInfoSchema = dbmdUsingInfoSchema.getTables(connInfoSchema.getCatalog(), null, "%", new String[] {"TABLE", "VIEW"});
+			
+			compareResultSets(rsShow, rsInfoSchema);
+			
+			rsShow = dbmdUsingShow.getTables(null, null, "%", new String[] {"TABLE", "VIEW"});
+			rsInfoSchema = dbmdUsingInfoSchema.getTables(null, null, "%", new String[] {"TABLE", "VIEW"});
+		
+			compareResultSets(rsShow, rsInfoSchema);
+			*/
+			
+			createTable("t_testBug23304", "(field1 int primary key not null, field2 tinyint, field3 mediumint, field4 mediumint, field5 bigint, field6 float, field7 double, field8 decimal, field9 char(32), field10 varchar(32), field11 blob, field12 mediumblob, field13 longblob, field14 text, field15 mediumtext, field16 longtext, field17 date, field18 time, field19 datetime, field20 timestamp)");
+			
+			rsShow = dbmdUsingShow.getColumns(connShow.getCatalog(), null, "t_testBug23304", "%");
+			rsInfoSchema = dbmdUsingInfoSchema.getColumns(connInfoSchema.getCatalog(), null, "t_testBug23304", "%");
+			
+			compareResultSets(rsShow, rsInfoSchema);
+		} finally {
+			if (rsShow != null) {
+				rsShow.close();
+			}
+			
+			if (rsInfoSchema != null) {
+				rsInfoSchema.close();
+			}
+		}
+	}
+	
+	private void compareResultSets(ResultSet expected, ResultSet actual) throws Exception {
+		if (expected == null && actual != null) {
+			fail("Expected null result set, actual was not null.");
+		} else if (expected != null && actual == null) {
+			fail("Expected non-null actual result set.");
+		} else if (expected == null && actual == null) {
+			return;
+		}
+		
+		expected.last();
+		
+		int expectedRows = expected.getRow();
+		
+		actual.last();
+		
+		int actualRows = actual.getRow();
+		
+		assertEquals(expectedRows, actualRows);
+		
+		ResultSetMetaData metadataExpected = expected.getMetaData();
+		ResultSetMetaData metadataActual = actual.getMetaData();
+		
+		assertEquals(metadataExpected.getColumnCount(), metadataActual.getColumnCount());
+		
+		for (int i = 0; i < metadataExpected.getColumnCount(); i++) {
+			assertEquals(metadataExpected.getColumnName(i + 1), metadataActual.getColumnName(i + 1));
+			assertEquals(metadataExpected.getColumnType(i + 1), metadataActual.getColumnType(i + 1));
+			assertEquals(metadataExpected.getColumnClassName(i + 1), metadataActual.getColumnClassName(i + 1));
+		}
+		
+		expected.beforeFirst();
+		actual.beforeFirst();
+		
+		StringBuffer messageBuf = null;
+		
+		while (expected.next() && actual.next()) {
+			
+			if (messageBuf != null) {
+				messageBuf.append("\n");
+			}
+			
+			for (int i = 0; i < metadataExpected.getColumnCount(); i++) {
+				if (expected.getObject(i + 1) == null && actual.getObject(i + 1) == null) {
+					continue;
+				}
+				
+				if ((expected.getObject(i + 1) == null && actual.getObject(i + 1) != null) ||
+						(expected.getObject(i + 1) != null && actual.getObject(i + 1) == null) ||
+						(!expected.getObject(i + 1).equals(actual.getObject(i + 1)))) {
+					if ("COLUMN_DEF".equals(metadataExpected.getColumnName(i + 1)) && 
+							(expected.getObject(i + 1) == null && actual.getString(i + 1).length() == 0) ||
+							(expected.getString(i + 1).length() == 0 && actual.getObject(i + 1) == null)) {
+						continue; // known bug with SHOW FULL COLUMNS, and we can't distinguish between null and ''
+						          // for a default
+					}
+					
+					if (messageBuf == null) {
+						messageBuf = new StringBuffer();
+					} else {
+						messageBuf.append("\n");
+					}
+					
+					messageBuf.append("On row " + expected.getRow() + " ,for column named " + metadataExpected.getColumnName(i + 1) + ", expected '" + expected.getObject(i + 1) + "', found '" + actual.getObject(i + 1) + "'");
+					
+				}
+			}
+		}
+		
+		if (messageBuf != null) {
+			fail(messageBuf.toString());
+		}
+	}
 }

Thread
Connector/J commit: r6133 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...mmatthews7 Dec