Skip to content

Commit

Permalink
DBZ-1252 Use if rather than switch
Browse files Browse the repository at this point in the history
  • Loading branch information
cwholmes authored and jpechane committed Sep 25, 2024
1 parent 8a42486 commit c8f18e4
Showing 1 changed file with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,19 @@ private String snapshotTransactionIsolationLevelStatement(SlotCreationResult new
return "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; \n" + snapSet;
}

final PostgresConnectorConfig.SnapshotIsolationMode isolationMode = connectorConfig.getSnapshotIsolationMode();
if (isolationMode == PostgresConnectorConfig.SnapshotIsolationMode.REPEATABLE_READ) {
return "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY;";
}
if (isolationMode == PostgresConnectorConfig.SnapshotIsolationMode.READ_COMMITTED) {
return "SET TRANSACTION ISOLATION LEVEL READ COMMITTED, READ ONLY;";
}
if (isolationMode == PostgresConnectorConfig.SnapshotIsolationMode.READ_UNCOMMITTED) {
return "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, READ ONLY;";
}
// DEFERRABLE only takes affect for READY ONLY and SERIALIZABLE
// https://www.postgresql.org/docs/current/sql-set-transaction.html
String transactionIsolationLevelStatement = "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE;";
switch (connectorConfig.getSnapshotIsolationMode()) {
case REPEATABLE_READ:
transactionIsolationLevelStatement = "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY;";
break;
case READ_COMMITTED:
transactionIsolationLevelStatement = "SET TRANSACTION ISOLATION LEVEL READ COMMITTED, READ ONLY;";
break;
case READ_UNCOMMITTED:
transactionIsolationLevelStatement = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, READ ONLY;";
break;
default:
break;
}
return transactionIsolationLevelStatement;
return "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE;";
}

/**
Expand Down

0 comments on commit c8f18e4

Please sign in to comment.