From da506473bd4dafc45a0cf84b15aa6a2ac5a75b89 Mon Sep 17 00:00:00 2001 From: rusher Date: Tue, 23 Apr 2024 09:55:13 +0200 Subject: [PATCH] [misc] metadata ensure correct join in case of using catalog in the future --- src/main/java/org/mariadb/jdbc/DatabaseMetaData.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java b/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java index d502f9fdf..e23eabfa2 100644 --- a/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java +++ b/src/main/java/org/mariadb/jdbc/DatabaseMetaData.java @@ -1034,7 +1034,8 @@ public ResultSet getExportedKeys(String catalog, String schema, String table) + " DEFERRABILITY" + " FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU" + " INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC" - + " ON KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA" + + " ON KCU.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG" + + " AND KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA" + " AND KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME"); String database = conf.useCatalogTerm() == CatalogTerm.UseCatalog ? catalog : schema; boolean firstCondition = @@ -1089,7 +1090,8 @@ public ResultSet getImportedKeysUsingInformationSchema(final String database, St + " DEFERRABILITY" + " FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU" + " INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC" - + " ON KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA" + + " ON KCU.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG" + + " AND KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA" + " AND KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME "); boolean firstCondition = databaseCond(true, sb, "KCU.TABLE_SCHEMA", database, false); @@ -2691,7 +2693,8 @@ public ResultSet getCrossReference( + " DEFERRABILITY " + "FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU" + " INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC" - + " ON KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA" + + " ON KCU.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG" + + " AND KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA" + " AND KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME "); String parentDatabase = conf.useCatalogTerm() == CatalogTerm.UseCatalog ? parentCatalog : parentSchema;