Source:
<code>public ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest) { long start = 0; Database database = session.getDatabase(); <START> Object sync = database.getMvStore() != null ? null : database.isMultiThreaded() ? session : database; <END> session.waitIfExclusiveModeEnabled(); boolean callStop = true; boolean writing = !isReadOnly(); if (writing) { while (!database.beforeWriting()) { } } Session.Savepoint rollback = session.setSavepoint(); session.startStatementWithinTransaction(); session.setCurrentCommand(this, generatedKeysRequest); try { while (true) { database.checkPowerOff(); try { int updateCount; if (sync != null) { synchronized (sync) { updateCount = update(); } } else { updateCount = update(); } if (!Boolean.FALSE.equals(generatedKeysRequest)) { return new ResultWithGeneratedKeys.WithKeys(updateCount, session.getGeneratedKeys().getKeys(session)); } return ResultWithGeneratedKeys.of(updateCount); } catch (DbException e) { start = filterConcurrentUpdate(e, start); } catch (OutOfMemoryError e) { callStop = false; database.shutdownImmediately(); throw DbException.convert(e); } catch (Throwable e) { throw DbException.convert(e); } } } catch (DbException e) { e = e.addSQL(sql); SQLException s = e.getSQLException(); database.exceptionThrown(s, sql); if (s.getErrorCode() == ErrorCode.OUT_OF_MEMORY) { callStop = false; database.shutdownImmediately(); throw e; } database.checkPowerOff(); if (s.getErrorCode() == ErrorCode.DEADLOCK_1) { session.rollback(); } else { session.rollbackTo(rollback, false); } throw e; } finally { try { if (callStop) { stop(); } } finally { if (writing) { database.afterWriting(); } } } }</code><technical_language>Session is locked invocation of this method in JdbcStatement.executeUpdateInternal(), executeInternal(), executeQuery() etc. change situations Session is locked all, transactional commands internal usages of SET command code paths in JdbcConnection/JdbcStatement synchronization. Is safe? If command executed time a normal command affect fields of session in unexpected way. For example, clear generated keys, override scope identities, currentCommandStart cancelAtNs</technical_language>

Target:
public ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest) { long start = 0; Database database = session.getDatabase(); Object sync = database.isMultiThreaded() || database.getMvStore() != null ? session : database; session.waitIfExclusiveModeEnabled(); boolean callStop = true; boolean writing = !isReadOnly(); if (writing) { while (!database.beforeWriting()) { } } synchronized (sync) { Session.Savepoint rollback = session.setSavepoint(); session.startStatementWithinTransaction(); session.setCurrentCommand(this, generatedKeysRequest); try { while (true) { database.checkPowerOff(); try { int updateCount = update(); if (!Boolean.FALSE.equals(generatedKeysRequest)) { return new ResultWithGeneratedKeys.WithKeys(updateCount, session.getGeneratedKeys().getKeys(session)); } return ResultWithGeneratedKeys.of(updateCount); } catch (DbException e) { start = filterConcurrentUpdate(e, start); } catch (OutOfMemoryError e) { callStop = false; database.shutdownImmediately(); throw DbException.convert(e); } catch (Throwable e) { throw DbException.convert(e); } } } catch (DbException e) { e = e.addSQL(sql); SQLException s = e.getSQLException(); database.exceptionThrown(s, sql); if (s.getErrorCode() == ErrorCode.OUT_OF_MEMORY) { callStop = false; database.shutdownImmediately(); throw e; } database.checkPowerOff(); if (s.getErrorCode() == ErrorCode.DEADLOCK_1) { session.rollback(); } else { session.rollbackTo(rollback, false); } throw e; } finally { try { if (callStop) { stop(); } } finally { if (writing) { database.afterWriting(); } } } } }