[CONJ-16] MySQLDatabaseMetaData.getColumns does not respect the catalog Created: 2013-01-18 Updated: 2013-02-03 Resolved: 2013-02-03 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.1.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | George El Boustani | Assignee: | Vladislav Vaintroub |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
MySQLDatabaseMetaData.getColumns is not respecting the catalog. This results in duplicate column entries in the result set when the same table structures exist in multiple catalogs. |
| Comments |
| Comment by Vladislav Vaintroub [ 2013-01-18 ] |
|
Could you please tell what are you passing to the function for 'catalog' parameter? |
| Comment by George El Boustani [ 2013-01-21 ] |
|
We are passing in the name of the catalog, the database name. So in this case "jira" |
| Comment by Vladislav Vaintroub [ 2013-01-21 ] |
|
The full (arguably big and ugly) query that I get for 1.1.0 driver with connection.getMetaData().getColumns("jira", null, null, null); is given below . WHERE clause has (TABLE_SCHEMA = 'jira') condition, so there is filtering by the database name. The result set, for me, is empty because I do not have database named Jira. I have 3 theories on how to explain an error on your side 1 . You're still using 1.0.0 driver. If you switch to 1.1.0 this will fix the problems Could you provide some more info so that I can figure out whether 1.,2.,or 3. is correct? Also, if you need the function to behave in a manner that is not compatible with JDBC spec, but with ConnectorJ instead (i.e if 2. Is true) could you please indicate that too? The Query: SELECT TABLE_SCHEMA TABLE_CAT, NULL TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, CASE data_type WHEN 'bit' THEN -7 WHEN 'tinyblob' THEN -4 WHEN 'mediumblob' THEN -4 WHEN 'longblob' THEN -4 WHEN 'blob' THEN -4 WHEN 'tinytext' THEN -1 WHEN 'mediumtext' THEN -1 WHEN 'longtext' THEN -1 WHEN 'text' THEN -1 WHEN 'date' THEN 91 WHEN 'datetime' THEN 93 WHEN 'decimal' THEN 3 WHEN 'double' THEN 8 WHEN 'enum' THEN 12 WHEN 'float' THEN 6 WHEN 'int' THEN IF(COLUMN_TYPE LIKE '%unsigned%', -5,4) WHEN 'bigint' THEN -5 WHEN 'mediumint' THEN 4 WHEN 'null' THEN 0 WHEN 'set' THEN 12 WHEN 'smallint' THEN IF(COLUMN_TYPE LIKE '%unsigned%', 4,5) WHEN 'varchar' THEN 12 WHEN 'varbinary' THEN -3 WHEN 'char' THEN 1 WHEN 'binary' THEN -2 WHEN 'time' THEN 92 WHEN 'timestamp' THEN 93 WHEN 'tinyint' THEN -6 WHEN 'year' THEN 91 ELSE 1111 END DATA_TYPE, UCASE(IF(COLUMN_TYPE LIKE '%(%)%', CONCAT (SUBSTRING(COLUMN_TYPE,1, LOCATE('(',COLUMN_TYPE) - 1), SUBSTRING(COLUMN_TYPE,1+ LOCATE(')',COLUMN_TYPE))), COLUMN_TYPE)) TYPE_NAME, CASE COLUMN_TYPE WHEN 'time' THEN 8 WHEN 'date' THEN 10 WHEN 'datetime' THEN 19 WHEN 'timestamp' THEN 19 ELSE IF(NUMERIC_PRECISION IS NULL, LEAST(CHARACTER_MAXIMUM_LENGTH,2147483647), 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, LEAST(CHARACTER_OCTET_LENGTH,2147483647) CHAR_OCTET_LENGTH, ORDINAL_POSITION, IS_NULLABLE, NULL SCOPE_CATALOG, NULL SCOPE_SCHEMA, NULL SCOPE_TABLE, NULL SOURCE_DATA_TYPE, IF(EXTRA = 'auto_increment','YES','NO') IS_AUTOINCREMENT |
| Comment by George El Boustani [ 2013-01-22 ] |
|
This is the call we are making: |
| Comment by Vladislav Vaintroub [ 2013-01-22 ] |
|
I see. You should be using catalog - the first parameter. In ConnectorJ, as well as (now, consistently) in mariadb-java-client, MySQL database(schema) is a JDBC catalog, whereas JDBC's schema is never used., |
| Comment by Vladislav Vaintroub [ 2013-02-03 ] |
|
implemented nullCatalogMeansCurrent feature, since you're relying on this. |