Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#11227] improvement(deps): Upgrade PostgreSQL JDBC driver from 42.6.0 to 42.7.11 (#11228)

geyanggangc54b2e3b6cd1
diff --git a/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java b/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
index 3866821f52..1df76e914d 100644
--- a/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
+++ b/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
@@ -120,12 +120,17 @@ public class PostgreSqlSchemaOperations extends JdbcDatabaseOperations {
*
* <p>Database in PG corresponds to Catalog in JDBC. Schema in PG corresponds to Schema in JDBC.
*
+ * <p>The catalog parameter is sourced from {@link Connection#getCatalog()} rather than the
+ * configured database field, because PostgreSQL JDBC driver 42.7+ strictly matches the catalog
+ * parameter against the connection's actual catalog. In PostgreSQL, a connection can only connect
+ * to a single database, and {@code setCatalog()} is effectively a no-op.
+ *
* @param connection the connection to the database
* @param schemaName the name of the schema
*/
private ResultSet getSchema(Connection connection, String schemaName) throws SQLException {
final DatabaseMetaData metaData = connection.getMetaData();
- return metaData.getSchemas(database, schemaName);
+ return metaData.getSchemas(connection.getCatalog(), schemaName);
}
@Override
diff --git a/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java b/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java
index ce1db26f20..a47e136e05 100644
--- a/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java
+++ b/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java
@@ -718,13 +718,14 @@ public class PostgreSqlTableOperations extends JdbcTableOperations
@Override
protected ResultSet getIndexInfo(String schemaName, String tableName, DatabaseMetaData metaData)
throws SQLException {
- return metaData.getIndexInfo(database, schemaName, tableName, false, false);
+ return metaData.getIndexInfo(
+ metaData.getConnection().getCatalog(), schemaName, tableName, false, false);
}
@Override
protected ResultSet getPrimaryKeys(String schemaName, String tableName, DatabaseMetaData metaData)
throws SQLException {
- return metaData.getPrimaryKeys(database, schemaName, tableName);
+ return metaData.getPrimaryKeys(metaData.getConnection().getCatalog(), schemaName, tableName);
}
@Override
@@ -739,14 +740,14 @@ public class PostgreSqlTableOperations extends JdbcTableOperations
protected ResultSet getTable(Connection connection, String schema, String tableName)
throws SQLException {
DatabaseMetaData metaData = connection.getMetaData();
- return metaData.getTables(database, schema, tableName, null);
+ return metaData.getTables(connection.getCatalog(), schema, tableName, null);
}
@Override
protected ResultSet getColumns(Connection connection, String schema, String tableName)
throws SQLException {
DatabaseMetaData metaData = connection.getMetaData();
- return metaData.getColumns(database, schema, tableName, null);
+ return metaData.getColumns(connection.getCatalog(), schema, tableName, null);
}
@Override
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index f33566817c..42ab37f844 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -88,7 +88,7 @@ clickhouse = "0.7.1"
lz4 = "1.8.0"
snappy-java = "1.1.10.8"
mysql = "8.0.33"
-postgresql = "42.6.0"
+postgresql = "42.7.11"
immutables-value = "2.11.7"
selenium = "4.33.0"
rauschig = "1.2.0"