Skip to content

Commit

Permalink
Fix regression with partitioned tables in PostgreSQL
Browse files Browse the repository at this point in the history
Add handling for detecting existence of partitioned tables explicitly.

PostgreSQL JDBC Driver update from 42.2.10 to 42.2.25 in #113 caused
partitioned tables to broke due upstream change of separating types of
normal table and partitioned table as explained in
pgjdbc/pgjdbc#1708
  • Loading branch information
tvainika committed Mar 3, 2022
1 parent e5b2b14 commit f7d2226
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -496,12 +496,15 @@ public boolean tableExists(
final Connection connection,
final TableId tableId
) throws SQLException {
final DatabaseMetaData metadata = connection.getMetaData();
final String[] tableTypes = tableTypes(metadata, new HashSet<>(Arrays.asList("TABLE", "PARTITIONED TABLE")));

log.info("Checking {} dialect for existence of table {}", this, tableId);
try (final ResultSet rs = connection.getMetaData().getTables(
tableId.catalogName(),
tableId.schemaName(),
tableId.tableName(),
new String[]{"TABLE"}
tableTypes
)) {
final boolean exists = rs.next();
log.info("Using {} dialect table {} {}", this, tableId, exists ? "present" : "absent");
Expand Down

0 comments on commit f7d2226

Please sign in to comment.