Bug #113970 DatabaseMetaData#getTables produces duplicates
Submitted: 13 Feb 6:34 Modified: 13 Feb 13:20
Reporter: Jin Kwon Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.3.0 OS:MacOS
Assigned to: CPU Architecture:Any

[13 Feb 6:34] Jin Kwon
Description:
DatabaseMetaData#getTables produces duplicates.

Two sets of duplicate tables are here.
(Only the `REMARKS` values are different.)

Table(super=AbstractMetadataType(super=com.github.jinahya.database.metadata.bind.Table@65c39a55, unmappedValues={}),
    tableCat=null,
    tableSchem=null,
    tableName=replication_asynchronous_connection_failover,
    tableType=SYSTEM TABLE,
    remarks=The source configuration details,
    typeCat=null, typeSchem=null, typeName=null, selfReferencingColName=null, refGeneration=null),

Table(super=AbstractMetadataType(super=com.github.jinahya.database.metadata.bind.Table@65c39a55, unmappedValues={}),
    tableCat=null,
    tableSchem=null,
    tableName=replication_asynchronous_connection_failover,
    tableType=SYSTEM TABLE,
    remarks=,
    typeCat=null, typeSchem=null, typeName=null, selfReferencingColName=null, refGeneration=null),

Table(super=AbstractMetadataType(super=com.github.jinahya.database.metadata.bind.Table@6a8d1d75, unmappedValues={}),
    tableCat=null,
    tableSchem=null,
    tableName=replication_asynchronous_connection_failover_managed,
    tableType=SYSTEM TABLE,
    remarks=The managed source configuration details,
    typeCat=null, typeSchem=null, typeName=null, selfReferencingColName=null, refGeneration=null),

Table(super=AbstractMetadataType(super=com.github.jinahya.database.metadata.bind.Table@6a8d1d75, unmappedValues={}),
    tableCat=null,
    tableSchem=null,
    tableName=replication_asynchronous_connection_failover_managed,
    tableType=SYSTEM TABLE,
    remarks=,
    typeCat=null, typeSchem=null, typeName=null, selfReferencingColName=null, refGeneration=null),

How to repeat:
Invoke `DatabaseMetaData#getTables(null, null, "%", null)`.

Suggested fix:
Suppress duplicates
[13 Feb 8:41] MySQL Verification Team
Hello Jin Kwon,

Thank you for the report and feedback.

regards,
Umesh
[13 Feb 8:50] MySQL Verification Team
I have verified for now, I could be wrong but this might turn out to be an expected behavior, if you closely look at the tables from both mysql and performance_schema, below tables are present in both the schema:

mysql> show tables from mysql;
+------------------------------------------------------+
| Tables_in_mysql                                      |
+------------------------------------------------------+
.
| replication_asynchronous_connection_failover         |
| replication_asynchronous_connection_failover_managed |
.
+------------------------------------------------------+
38 rows in set (0.00 sec)

mysql> show tables from performance_schema;
+------------------------------------------------------+
| Tables_in_performance_schema                         |
+------------------------------------------------------+
.
| replication_asynchronous_connection_failover         |
| replication_asynchronous_connection_failover_managed |
.
+------------------------------------------------------+
111 rows in set (0.00 sec)

Only diff being the table level COMMENT missing in performance_schema tables(above).
[13 Feb 13:20] Jin Kwon
The the problem will be the `TABLE_CAT` and/or `TABLE_SCHEM` which either should have the different value(`mysql`, `performance_schema`).