[Commits] Rev 397: CONJ-15 - DatabaseMedataData.getColumns() returned incorrect value in "COLUMN_SIZE" column for character data. in file:///H:/bzr/mariadb-jdbc-push/

Vladislav Vaintroub wlad at montyprogram.com
Sat Feb 2 15:37:48 EET 2013


At file:///H:/bzr/mariadb-jdbc-push/

------------------------------------------------------------
revno: 397
revision-id: wlad at montyprogram.com-20130202133714-1qc4us4xuzisbuvg
parent: wlad at montyprogram.com-20130202123504-i0oociz534qp0xk0
fixes bug: https://mariadb.atlassian.net/browse/CONJ-15
committer: Vladislav Vaintroub <wlad at montyprogram.com>
branch nick: mariadb-jdbc-push
timestamp: Sat 2013-02-02 14:37:14 +0100
message:
  CONJ-15 - DatabaseMedataData.getColumns() returned incorrect value in "COLUMN_SIZE" column for character data.
  
  Fix is to use I_S.COLUMNS.CHARACTER_MAXIMUM_LENGTH instead of I_IS.COLUMNS.CHARACTER_OCTET_LENGTH
  to calculate COLUMN_SIZE
  
  Also, return COLUMN_SIZE for temporal datatypes instead of NULL.
-------------- next part --------------
=== modified file 'src/main/java/org/mariadb/jdbc/MySQLDatabaseMetaData.java'
--- a/src/main/java/org/mariadb/jdbc/MySQLDatabaseMetaData.java	2013-02-02 12:35:04 +0000
+++ b/src/main/java/org/mariadb/jdbc/MySQLDatabaseMetaData.java	2013-02-02 13:37:14 +0000
@@ -240,7 +240,14 @@ public class MySQLDatabaseMetaData imple
         "SELECT TABLE_SCHEMA TABLE_CAT, NULL TABLE_SCHEM, TABLE_NAME, COLUMN_NAME," 
         + dataTypeClause("COLUMN_TYPE") + " DATA_TYPE,"
         + columnTypeClause("COLUMN_TYPE") +" TYPE_NAME, "
-        + " IF(NUMERIC_PRECISION IS NULL, LEAST(CHARACTER_OCTET_LENGTH,"+Integer.MAX_VALUE+"), NUMERIC_PRECISION) " 
+        + " CASE COLUMN_TYPE"
+        + "  WHEN 'time' THEN 8"
+        + "  WHEN 'date' THEN 10"       /* TODO : microseconds */
+        + "  WHEN 'datetime' THEN 19"   
+        + "  WHEN 'timestamp' THEN 19"
+        + "  ELSE "
+        + "  IF(NUMERIC_PRECISION IS NULL, LEAST(CHARACTER_MAXIMUM_LENGTH,"+Integer.MAX_VALUE+"), NUMERIC_PRECISION) "
+        + " END" 
         + " COLUMN_SIZE, 65535 BUFFER_LENGTH, NUMERIC_SCALE DECIMAL_DIGITS,"  
         + " 10 NUM_PREC_RADIX, IF(IS_NULLABLE = 'yes',1,0) NULLABLE,COLUMN_COMMENT REMARKS," 
         + " COLUMN_DEFAULT COLUMN_DEF, 0 SQL_DATA_TYPE, 0 SQL_DATETIME_SUB,  "  

=== modified file 'src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java'
--- a/src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java	2013-02-02 12:35:04 +0000
+++ b/src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java	2013-02-02 13:37:14 +0000
@@ -510,6 +510,9 @@ public class DatabaseMetadataTest extend
             checkType(columnName, type, "text_col", Types.LONGVARCHAR);
             checkType(columnName, type, "mediumtext_col", Types.LONGVARCHAR);
             checkType(columnName, type, "longtext_col", Types.LONGVARCHAR);
+            if (columnName.equals("char_col")) {
+                assertEquals(rs.getInt("COLUMN_SIZE"),5);
+            }
         }
     }
 



More information about the commits mailing list