From e7dc1dfb6216a6965d31b6697ce9efad9d56acf1 Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Mon, 19 Aug 2019 12:40:43 -0400 Subject: [PATCH] DBZ-1440 Use ServerVersion values instead of integers --- .../postgresql/connection/PostgresReplicationConnection.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/connection/PostgresReplicationConnection.java b/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/connection/PostgresReplicationConnection.java index 5bf1de236..491bd0d8d 100644 --- a/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/connection/PostgresReplicationConnection.java +++ b/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/connection/PostgresReplicationConnection.java @@ -23,6 +23,7 @@ import java.util.function.Function; import org.apache.kafka.connect.errors.ConnectException; +import org.postgresql.core.ServerVersion; import org.postgresql.jdbc.PgConnection; import org.postgresql.replication.LogSequenceNumber; import org.postgresql.replication.PGReplicationStream; @@ -204,7 +205,7 @@ else if (shouldCreateSlot || !slotInfo.hasValidFlushedLsn()) { // Temporary replication slots is a new feature of PostgreSQL 10 private boolean useTemporarySlot() throws SQLException { - return dropSlotOnClose && pgConnection().haveMinimumServerVersion(100000); + return dropSlotOnClose && pgConnection().haveMinimumServerVersion(ServerVersion.v10); } /** @@ -271,7 +272,7 @@ public Optional createReplicationSlot() throws SQLException LOGGER.debug("Creating new replication slot '{}' for plugin '{}'", slotName, plugin); String tempPart = ""; // Exported snapshots are supported in PostgreSQL 9.4+ - Boolean canExportSnapshot = pgConnection().haveMinimumServerVersion(90400); + Boolean canExportSnapshot = pgConnection().haveMinimumServerVersion(ServerVersion.v9_4); if ((dropSlotOnClose || exportSnapshot) && !canExportSnapshot) { LOGGER.warn("A slot marked as temporary or with an exported snapshot was created, " + "but not on a supported version of Postgres, ignoring!");