This is an automated email from the ASF dual-hosted git repository.
mchades pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new c54b2e3b6c [#11227] improvement(deps): Upgrade PostgreSQL JDBC driver
from 42.6.0 to 42.7.11 (#11228)
c54b2e3b6c is described below
commit c54b2e3b6cd11e3297983d093cd89342528e2533
Author: geyanggang <[email protected]>
AuthorDate: Thu May 28 11:21:42 2026 +0800
[#11227] improvement(deps): Upgrade PostgreSQL JDBC driver from 42.6.0 to
42.7.11 (#11228)
### What changes were proposed in this pull request?
1. Upgrade `org.postgresql:postgresql` from 42.6.0 to 42.7.11 in
`libs.versions.toml`.
2. Adapt `PostgreSqlSchemaOperations` and `PostgreSqlTableOperations` to
use `Connection#getCatalog()` as the catalog parameter when calling
`DatabaseMetaData` APIs (`getSchemas`, `getTables`, `getColumns`,
`getIndexInfo`, `getPrimaryKeys`).
### Why are the changes needed?
The current version 42.6.0 is outdated. Version 42.7.11 includes bug
fixes and stability improvements.
PostgreSQL JDBC 42.7+ changed `DatabaseMetaData` behavior so that the
`catalog` parameter is strictly matched against the connection's actual
catalog. The previous code passed the configured `database` field, which
may not equal `connection.getCatalog()` in all environments, causing
`NoSuchNamespaceException` in integration tests after the upgrade.
Sourcing the catalog from `Connection#getCatalog()` aligns with the
connection's real state and works correctly across both 42.6.x and
42.7+.
Fix: #11227
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
- Compiled `catalog-jdbc-postgresql` and dependent test modules
- Ran `SparkJdbcPostgreSqlCatalogIT33` integration test — BUILD
SUCCESSFUL
- Ran full project unit tests — BUILD SUCCESSFUL
- PostgreSQL JDBC 42.7.x is fully compatible with PostgreSQL 13 (used in
integration tests)
---
.../catalog/postgresql/operation/PostgreSqlSchemaOperations.java | 7 ++++++-
.../catalog/postgresql/operation/PostgreSqlTableOperations.java | 9 +++++----
gradle/libs.versions.toml | 2 +-
3 files changed, 12 insertions(+), 6 deletions(-)
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"