Skip to content

Commit

Permalink
Spec-compliant fix for Bug#58751.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark.matthews@oracle.com committed Dec 6, 2010
1 parent e7c533b commit ade999b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
9 changes: 5 additions & 4 deletions CHANGES
@@ -1,12 +1,13 @@
# Changelog
# $Id$

mm-dd-10 - Version 5.1.14
12-07-10 - Version 5.1.14

- Fix for Bug#58728, NPE in com.mysql.jdbc.jdbc2.optional.StatementWrappe.getResultSet()
if rs is null. Regression test case added to Statementys regression tests.
if rs is null. Regression test case added to Statement regression tests.

- Fix for Bug#58751, DatabaseMetadata.getIndexInfo() CARDINALITY changed to Types.BIGINT.
MetadataRegression test changed accordingly.
- Fix for Bug#58751, DatabaseMetadata.getIndexInfo() CARDINALITY now clamped
to Integer.MAX_VALUE.

- Fix for BUG#58590
- Testsuite.Simple.DateTest, MetadataTest, NumbersTest and StatementsTest cleaned and fixed.
Expand Down
13 changes: 11 additions & 2 deletions src/com/mysql/jdbc/DatabaseMetaData.java
Expand Up @@ -3584,7 +3584,16 @@ void forEach(Object catalogStr) throws SQLException {
row[7] = results.getBytes("Seq_in_index");
row[8] = results.getBytes("Column_name");
row[9] = results.getBytes("Collation");
row[10] = results.getBytes("Cardinality");

// Cardinality can be much larger than Integer's range,
// so we clamp it to conform to the API
long cardinality = results.getLong("Cardinality");

if (cardinality > Integer.MAX_VALUE) {
cardinality = Integer.MAX_VALUE;
}

row[10] = s2b(String.valueOf(cardinality));
row[11] = s2b("0");
row[12] = null;

Expand Down Expand Up @@ -3633,7 +3642,7 @@ protected Field[] createIndexInfoFields() {
fields[7] = new Field("", "ORDINAL_POSITION", Types.SMALLINT, 5);
fields[8] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
fields[9] = new Field("", "ASC_OR_DESC", Types.CHAR, 1);
fields[10] = new Field("", "CARDINALITY", Types.BIGINT, 20);
fields[10] = new Field("", "CARDINALITY", Types.INTEGER, 20);
fields[11] = new Field("", "PAGES", Types.INTEGER, 10);
fields[12] = new Field("", "FILTER_CONDITION", Types.CHAR, 32);
return fields;
Expand Down
2 changes: 1 addition & 1 deletion src/testsuite/regression/MetaDataRegressionTest.java
Expand Up @@ -2498,7 +2498,7 @@ private void checkABunchOfReturnTypesForConnection(Connection mdConn)
// "A" => ascending, "D" => descending, may be null
// if sort sequence is not supported; null when TYPE
// is tableIndexStatistic
Types.BIGINT, // 11. CARDINALITY int => When TYPE is
Types.INTEGER, // 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.
Expand Down

0 comments on commit ade999b

Please sign in to comment.