Bug #87826 MySQL JDBC Connector/J DatabaseMetaData null pattern handling is non-compliant
Submitted: 21 Sep 2017 13:51 Modified: 4 Jan 2018 1:18
Reporter: Simon Greatrix Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any

[21 Sep 2017 13:51] Simon Greatrix
Description:
The connection parameter nullNamePatternMatchesAll should default to true.

The JavaDoc page:

https://docs.oracle.com/javase/8/docs/api/java/sql/DatabaseMetaData.html

specifically states that:

Quote
Some DatabaseMetaData methods take arguments that are String patterns. These arguments all have names such as fooPattern. Within a pattern String, "%" means match any substring of 0 or more characters, and "_" means match any one character. Only metadata entries matching the search pattern are returned. If a search pattern argument is set to null, that argument's criterion will be dropped from the search.
Unquote

The JDBC Specification itself makes no comments either way about how null should be treated in these methods.

By having nullNamePatternMatchesAll default to false, the implementation is not compliant with the JavaDoc.

How to repeat:
Invoke:

DatabaseMetaData.getProcedureColumns("myCatalog","mySchema,"myProcedure",null);

Expected result - ResultSet describing all columns for the stored procedure.

Actual result - throws SQLException

Suggested fix:
Change the default for nullNamePatternMatchesAll
[22 Sep 2017 7:11] Chiranjeevi Battula
Hello Simon,

Thank you for the bug report.
Verified this behavior on MySQL Connector / J 8.0.7 dmr.

Thanks,
Chiranjeevi.
[2 Oct 2017 10:19] Alexander Soklakov
Hi Simon,

Thanks, is really makes sense to change nullNamePatternMatchesAll default back to true. And even remove nullNamePatternMatchesAll option from c/J 8.0.
[16 Oct 2017 12:50] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=88091 marked as duplicate of this one.
[16 Oct 2017 15:52] Pala Dox
The default value was changed in https://github.com/mysql/mysql-connector-j/commit/8d34e91534b3fe68aef9eca7ddff9602ef4c5e0d
[4 Jan 2018 1:18] Daniel So
Posted by developer:
 
Added the following entry to the Connector/J 8.0.9 changelog:

"The connection property nullNamePatternMatchesAll, when set to false (which was the default value), caused some DatabaseMetaData methods to throw an error when a null search string was used with them. The behavior was not compliant with the JDBC specification, which requires that a search criterion be ignored when a null search string is used for it. The connection property has now been removed from Connector/J 8.0."