Bug #100878 JDBC getColumns() api doesn't consider schema with underscore(_)
Submitted: 17 Sep 2020 12:14 Modified: 13 May 2021 15:23
Reporter: Pravakar Panigrahi Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:8.0.21 OS:Any
Assigned to: CPU Architecture:Any
Tags: regression

[17 Sep 2020 12:14] Pravakar Panigrahi
Description:
While fetching results from getColumns() api, the schema name with underscore(_) character is not recognized

How to repeat:
1. Create 2 schema - my_schema, my1schema
2. Create table "newtable" in schema "my1schema"
3. Call JDBC getColumns api with table "newtable" and schema "my_schema"
4. Expectation is null results should be returned
5. Actual is table is getting fetched from "my1schema"
[17 Sep 2020 12:17] Pravakar Panigrahi
java program to recreate the issue

Attachment: mysql_bug_100878.txt (text/plain), 1.23 KiB.

[17 Sep 2020 12:50] MySQL Verification Team
Hello Pravakar,

Thank you for the report and test case.

regards,
Umesh
[17 Sep 2020 15:43] Rahul Dhuvad
Just to add further, our expectation is when schemaPattern contains any of the regex wild-card, using escape character sequence (\\) should help having the exact match instead of continue to treat it as a pattern.

For in the attached program:
dbMetaData.getColumns(null, "my\\_schema", "newtable", "%");
- should return columns of "newtable" table ONLY of "my_schema" schema
Whereas:
dbMetaData.getColumns(null, "my_schema", "newtable", "%");
- should return columns of "newtable" table of all patterns of "my_schema" schemas (where underscore is a single character wild-card)
[13 May 2021 15:22] Alexander Soklakov
Hi guys,

It's not a bug at all. You need to set databaseTerm=SCHEMA in your connection properties if you want to use schema pattern. Please read https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-connp-props-connection.html#cj-co... for explanation.