MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mmatthews Date:May 20 2008 9:10pm
Subject:Connector/J commit: r6772 - in branches/branch_5_1: . src/com/mysql/jdbc src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_1/CHANGES
   branches/branch_5_1/src/com/mysql/jdbc/DatabaseMetaData.java
   branches/branch_5_1/src/testsuite/regression/MetaDataRegressionTest.java
Log:
Fixed BUG#36830 - DBMD.getColumns() doesn't return correct COLUMN_SIZE for SET columns. The
	  logic wasn't accounting for the ","s in the column size.

Modified: branches/branch_5_1/CHANGES
===================================================================
--- branches/branch_5_1/CHANGES	2008-04-19 01:13:36 UTC (rev 6771)
+++ branches/branch_5_1/CHANGES	2008-05-20 21:10:40 UTC (rev 6772)
@@ -33,6 +33,9 @@
 	- Fixed BUG#36051 - ResultSet.getTime() won't accept value of '24' for hours component of
 	  a java.sql.Time.
 	  
+	- Fixed BUG#36830 - DBMD.getColumns() doesn't return correct COLUMN_SIZE for SET columns. The
+	  logic wasn't accounting for the ","s in the column size.
+	  
 03-06-08 - Version 5.1.6
 
     - JDBC-4.0-ized XAConnections and datasources.

Modified: branches/branch_5_1/src/com/mysql/jdbc/DatabaseMetaData.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/DatabaseMetaData.java	2008-04-19 01:13:36 UTC (rev 6771)
+++ branches/branch_5_1/src/com/mysql/jdbc/DatabaseMetaData.java	2008-05-20 21:10:40 UTC (rev 6772)
@@ -223,12 +223,18 @@
 				this.columnSize = Constants.integerValueOf(maxLength);
 				this.decimalDigits = null;
 			} else if (StringUtils.startsWithIgnoreCase(typeInfo, "set")) {
-				String temp = typeInfo.substring(typeInfo.indexOf("("),
+				String temp = typeInfo.substring(typeInfo.indexOf("(") + 1,
 						typeInfo.lastIndexOf(")"));
 				java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(
 						temp, ",");
 				int maxLength = 0;
 
+				int numElements = tokenizer.countTokens();
+				
+				if (numElements > 0) {
+					maxLength += (numElements - 1);
+				}
+				
 				while (tokenizer.hasMoreTokens()) {
 					String setMember = tokenizer.nextToken().trim();
 

Modified: branches/branch_5_1/src/testsuite/regression/MetaDataRegressionTest.java
===================================================================
--- branches/branch_5_1/src/testsuite/regression/MetaDataRegressionTest.java	2008-04-19 01:13:36 UTC (rev 6771)
+++ branches/branch_5_1/src/testsuite/regression/MetaDataRegressionTest.java	2008-05-20 21:10:40 UTC (rev 6772)
@@ -1637,7 +1637,7 @@
 	 */
 	public void testBug22613() throws Exception {
 		
-		createTable("bug22613", "( s set('a','bc','def','ghij') default NULL, t enum('a', 'ab', 'cdef'))");
+		createTable("bug22613", "( s set('a','bc','def','ghij') default NULL, t enum('a', 'ab', 'cdef'), s2 SET('1','2','3','4','1585','ONE','TWO','Y','N','THREE'))");
 
 		try {
 			checkMetadataForBug22613(this.conn);
@@ -1665,14 +1665,20 @@
 	
 	private void checkMetadataForBug22613(Connection c) throws Exception {
 		String maxValue = "a,bc,def,ghij";
+		String maxValue2 = "1,2,3,4,1585,ONE,TWO,Y,N,THREE";
 		
 		try {
 			DatabaseMetaData meta = c.getMetaData();
 			this.rs = meta.getColumns(null, this.conn.getCatalog(), "bug22613", "s");
 			this.rs.first();
-
+			
 			assertEquals(maxValue.length(), rs.getInt("COLUMN_SIZE"));
 			
+			this.rs = meta.getColumns(null, this.conn.getCatalog(), "bug22613", "s2");
+			this.rs.first();
+			
+			assertEquals(maxValue2.length(), rs.getInt("COLUMN_SIZE"));
+			
 			this.rs = meta.getColumns(null, c.getCatalog(), "bug22613", "t");
 			this.rs.first();
 

Thread
Connector/J commit: r6772 - in branches/branch_5_1: . src/com/mysql/jdbc src/testsuite/regressionmmatthews20 May