Bug #9778 getTables() ignores type parameter
Submitted: 9 Apr 2005 0:24 Modified: 11 Apr 2005 16:03
Reporter: Joel Brown Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.17 OS:Windows (XP)
Assigned to: Mark Matthews CPU Architecture:Any

[9 Apr 2005 0:24] Joel Brown
Description:

databaseMetaData.getTables() ignores the type parameter.

I call
databaseMetaData.getTables(null, null, "%", new String[] {"VIEW"} )
against a db with only TABLEs.

expected results:  empty resultset, since I have no VIEWs.

Actual results:  non-empty resultset - it returns TABLE types

I check the TABLE_TYPE column in the returned resultset and that returns "TABLE".  Good - so my workaround is to check the returned TABLE_TYPE, but I shouldn't have to do that.

Server is 4.0.18-nt

How to repeat:
something like this:

            java.sql.DatabaseMetaData dbMetaData = myConn.getMetaData() ;
            
            rs = dbMetaData.getTables(null,schemaName,"%", new String[] {"VIEW"}) ;

           if ( rs.next() ) {
                   // should never be here, since we have no VIEWs.
                   if ( ! "VIEW".equals(rs.getString("TABLE_TYPE") ) ) {
                           System.out.println("hosed.") :
                   }
           )

Suggested fix:
only return tables of the asked-for table type.
[11 Apr 2005 14:54] Mark Matthews
I assume you're referring to Connector/J 3.1.7. If so, please test the nightly snapshot of 3.1 from http://downloads.mysql.com/snapshots.php as it _should_ fix this problem (the issue was seen earlier in an unrelated bug).
[11 Apr 2005 15:41] Joel Brown
I still see the problem in 
mysql-connector-java-3.1-nightly-20050411-bin.jar
[11 Apr 2005 16:03] Mark Matthews
Fixed for 3.1.8. You can check out tonight's nightly build with the fix after Apr. 12th, 00:00 GMT from http://downloads.mysql.com/snapshots.php