Skip to content

Commit

Permalink
[misc] metadata ensure correct join in case of using catalog in the f…
Browse files Browse the repository at this point in the history
…uture
  • Loading branch information
rusher committed Apr 23, 2024
1 parent 4a0b526 commit da50647
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/mariadb/jdbc/DatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit da50647

Please sign in to comment.