#2089 - Postgres - Use NO KEY with FOR UPDATE clauses with Postgres

Rename PlatformConfig.defaultLockWithKey to PlatformConfig.forUpdateNoKey
This commit is contained in:
rob bygrave committed 2020-11-24 23:58:58 +13:00
1 parent 92a4bfb38e
commit 20fc74219a
5 files changed
+33 -18

No files matched your search

@@ -496,16 +496,31 @@ class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expression
return exprList.forUpdate();
}
@Override
public Query<T> forUpdate(Query.LockType lockType) {
return exprList.forUpdate(lockType);
}
@Override
public Query<T> forUpdateNoWait() {
return exprList.forUpdateNoWait();
}
@Override
public Query<T> forUpdateNoWait(Query.LockType lockType) {
return exprList.forUpdateNoWait(lockType);
}
@Override
public Query<T> forUpdateSkipLocked() {
return exprList.forUpdateSkipLocked();
}
@Override
public Query<T> forUpdateSkipLocked(Query.LockType lockType) {
return exprList.forUpdateSkipLocked(lockType);
}
/**
* Path exists - for the given path in a JSON document.
*/
@@ -73,7 +73,7 @@ public class ServerConfigTest {
props.setProperty("caseSensitiveCollation", "false");
props.setProperty("loadModuleInfo", "true");
props.setProperty("collectQueryPlanThresholdMicros", "10000");
props.setProperty("lockWithKey", "false");
props.setProperty("forUpdateNoKey", "true");
serverConfig.loadFromProperties(props);
@@ -85,7 +85,7 @@ public class ServerConfigTest {
assertTrue(serverConfig.isIdGeneratorAutomatic());
assertFalse(serverConfig.getPlatformConfig().isCaseSensitiveCollation());
assertFalse(serverConfig.getPlatformConfig().isLockWithKey());
assertTrue(serverConfig.getPlatformConfig().isForUpdateNoKey());
assertThat(serverConfig.getNamingConvention()).isInstanceOf(MatchingNamingConvention.class);
@@ -29,7 +29,7 @@ public class PostgresPlatformTest {
PlatformConfig config = new PlatformConfig();
platform.configure(config);
assertThat(config.isLockWithKey()).isTrue();
assertThat(config.isForUpdateNoKey()).isFalse();
assertThat(platform.withForUpdate("X", Query.ForUpdate.SKIPLOCKED, Query.LockType.Default)).isEqualTo("X for update skip locked");
assertThat(platform.withForUpdate("X", Query.ForUpdate.NOWAIT, Query.LockType.Default)).isEqualTo("X for update nowait");
assertThat(platform.withForUpdate("X", Query.ForUpdate.BASE, Query.LockType.Default)).isEqualTo("X for update");
@@ -56,10 +56,10 @@ public class PostgresPlatformTest {
DatabasePlatform platform = new PostgresPlatform();
PlatformConfig config = new PlatformConfig();
config.setLockWithKey(false);
config.setForUpdateNoKey(true);
platform.configure(config);
assertThat(config.isLockWithKey()).isFalse();
assertThat(config.isForUpdateNoKey()).isTrue();
assertThat(platform.withForUpdate("X", Query.ForUpdate.SKIPLOCKED, Query.LockType.Default)).isEqualTo("X for no key update skip locked");
assertThat(platform.withForUpdate("X", Query.ForUpdate.NOWAIT, Query.LockType.Default)).isEqualTo("X for no key update nowait");
assertThat(platform.withForUpdate("X", Query.ForUpdate.BASE, Query.LockType.Default)).isEqualTo("X for no key update");