Bug #44869 getIndexInfo does not return resultset as per JDBC API specifications
Submitted: 14 May 2009 10:23 Modified: 26 May 2009 10:54
Reporter: Vivekanand Bachche Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.7 OS:Windows
Assigned to: CPU Architecture:Any

[14 May 2009 10:23] Vivekanand Bachche
Description:
Result set returned by getIndexInfo (Database metadata) does not have format as defined in the specifications. Fourth column of the result set is expected to be of type ‘boolean’ where MySQL driver returns it as ‘char’.

This can give critical problems with BI tools which perform strict checking before retreiving metadata information.

How to repeat:
public void testMetadata() {

               Class.forName("com.mysql.jdbc.Driver");
               Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb?user=myself&password=mypassword");
               ResultSet rs = metadata.getIndexInfo(null, null, null, false, false);
       ResultSetMetaData rsmd = rs.getMetaData();
       System.out.println("Column Name is : " + rsmd.getColumnName(4));	// It is “NON_UNIQUE”
       System.out.println("Column Type is : " + rsmd.getColumnType(4));	// Expected type here is Boolean i.e. 16, it returns 1 (char)
}
[14 May 2009 10:43] Vivekanand Bachche
Logical cause and fix looks to be simialar for following bugs-
44791
44862
44863
44865
44867
44868
44869
[14 May 2009 11:11] Vivekanand Bachche
Please exclude 44791 from the list in my previous comment.
[14 May 2009 16:44] Valeriy Kravchuk
Thank you for the problem report.
[22 May 2009 20:54] Mark Matthews
Fixed, see http://bazaar.launchpad.net/~mark-mysql/connectorj/5.1/revision/793
[26 May 2009 10:54] Tony Bedford
An entry has been added to the 5.1.8 changelog:

The result set returned by getIndexInfo() did not have the format defined in the JDBC API specifications. The fourth column, DATA_TYPE, of the result set should be of type BOOLEAN. Connector/J however returns CHAR.
[6 Dec 2010 11:49] Tonci Grgin
This will be changed in relation to Bug#58751:
Types.BIGINT, // 11. CARDINALITY int => When TYPE is
		// tableIndexStatistic, then this is the number
		// of rows in the table; otherwise, it is the
		// number of unique values in the index.

because previous definition (INT) supports only ~2.2 billion rows.