"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hsqldb/src/org/hsqldb/Session.java" between
hsqldb-2.7.1.zip and hsqldb-2.7.2.zip

About: HSQLDB (HyperSQL DataBase) is a SQL relational database engine written in Java. It supports nearly full ANSI-92 SQL (BNF format) and full core SQL:2008.

Session.java  (hsqldb-2.7.1):Session.java  (hsqldb-2.7.2)
/* Copyright (c) 2001-2022, The HSQL Development Group /* Copyright (c) 2001-2023, The HSQL Development Group
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright notice, this * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* Redistributions in binary form must reproduce the above copyright notice, * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
skipping to change at line 36 skipping to change at line 36
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package org.hsqldb; package org.hsqldb;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Random; import java.util.Random;
import java.util.TimeZone; import java.util.TimeZone;
import org.hsqldb.HsqlNameManager.HsqlName; import org.hsqldb.HsqlNameManager.HsqlName;
import org.hsqldb.error.Error; import org.hsqldb.error.Error;
import org.hsqldb.error.ErrorCode; import org.hsqldb.error.ErrorCode;
import org.hsqldb.jdbc.JDBCConnection; import org.hsqldb.jdbc.JDBCConnection;
import org.hsqldb.jdbc.JDBCDriver; import org.hsqldb.jdbc.JDBCDriver;
import org.hsqldb.lib.ArrayUtil; import org.hsqldb.lib.ArrayUtil;
import org.hsqldb.lib.CountUpDownLatch; import org.hsqldb.lib.CountUpDownLatch;
skipping to change at line 77 skipping to change at line 76
import org.hsqldb.types.DateTimeType; import org.hsqldb.types.DateTimeType;
import org.hsqldb.types.TimeData; import org.hsqldb.types.TimeData;
import org.hsqldb.types.TimestampData; import org.hsqldb.types.TimestampData;
import org.hsqldb.types.Type; import org.hsqldb.types.Type;
import org.hsqldb.types.TypedComparator; import org.hsqldb.types.TypedComparator;
/** /**
* Implementation of SQL sessions. * Implementation of SQL sessions.
* *
* @author Fred Toussi (fredt@users dot sourceforge.net) * @author Fred Toussi (fredt@users dot sourceforge.net)
* @version 2.7.1 * @version 2.7.2
* @since 1.7.0 * @since 1.7.0
*/ */
public class Session implements SessionInterface { public class Session implements SessionInterface {
// //
private volatile boolean isClosed; private volatile boolean isClosed;
// //
public Database database; public Database database;
private final User sessionUser; private final User sessionUser;
skipping to change at line 104 skipping to change at line 103
int isolationLevel = SessionInterface.TX_READ_COMMITTED; int isolationLevel = SessionInterface.TX_READ_COMMITTED;
boolean isReadOnlyIsolation; boolean isReadOnlyIsolation;
int actionIndex; int actionIndex;
long actionStartSCN; long actionStartSCN;
long actionSCN; long actionSCN;
long statementStartSCN; long statementStartSCN;
long transactionSCN; long transactionSCN;
long transactionEndSCN; long transactionEndSCN;
final boolean txConflictRollback; final boolean txConflictRollback;
final boolean txInterruptRollback; final boolean txInterruptRollback;
boolean isPreTransaction; volatile boolean isPreTransaction;
boolean isTransaction; volatile boolean isTransaction;
boolean isBatch; boolean isBatch;
volatile boolean abortAction; volatile boolean abortAction;
volatile boolean abortTransaction; volatile boolean abortTransaction;
volatile boolean redoAction; volatile boolean redoAction;
HsqlArrayList rowActionList; HsqlArrayList rowActionList;
volatile boolean tempUnlocked; volatile boolean tempUnlocked;
public OrderedHashSet waitedSessions; public OrderedHashSet waitedSessions;
public OrderedHashSet waitingSessions; public OrderedHashSet waitingSessions;
OrderedHashSet tempSet; OrderedHashSet tempSet;
OrderedHashSet actionSet; OrderedHashSet actionSet;
skipping to change at line 155 skipping to change at line 154
int resultMaxMemoryRows; int resultMaxMemoryRows;
// //
public SessionData sessionData; public SessionData sessionData;
// //
public StatementManager statementManager; public StatementManager statementManager;
// //
public Object special; public Object special;
public int sessionTxId;
/** /**
* Constructs a new Session object. * Constructs a new Session object.
* @param db the database to which this represents a connection * @param db the database to which this represents a connection
* @param user the initial user * @param user the initial user
* @param autocommit the initial autocommit value * @param autocommit the initial autocommit value
* @param readonly the initial readonly value * @param readonly the initial readonly value
* @param id the session identifier, as known to the database * @param id the session identifier, as known to the database
* @param zone the TimeZone * @param zone the TimeZone
*/ */
skipping to change at line 627 skipping to change at line 627
rollbackNoCheck(chain); rollbackNoCheck(chain);
} }
synchronized void rollbackNoCheck(boolean chain) { synchronized void rollbackNoCheck(boolean chain) {
if (isClosed) { if (isClosed) {
return; return;
} }
if (isTransaction) { if (isTransaction || isPreTransaction) {
database.txManager.rollback(this); database.txManager.rollback(this);
} }
endTransaction(false, chain); endTransaction(false, chain);
} }
private void endTransaction(boolean commit, boolean chain) { private void endTransaction(boolean commit, boolean chain) {
abortAction = false; abortAction = false;
abortTransaction = false; abortTransaction = false;
skipping to change at line 663 skipping to change at line 663
if (database.logger.getSqlEventLogLevel() > 0) { if (database.logger.getSqlEventLogLevel() > 0) {
Statement endTX = commit ? StatementSession.commitNoChainStatement Statement endTX = commit ? StatementSession.commitNoChainStatement
: StatementSession : StatementSession
.rollbackNoChainStatement; .rollbackNoChainStatement;
database.logger.logStatementEvent(this, endTX, null, database.logger.logStatementEvent(this, endTX, null,
Result.updateZeroResult, Result.updateZeroResult,
SimpleLog.LOG_ERROR); SimpleLog.LOG_ERROR);
} }
/* debug 190 /* debug 190
tempActionHistory.add("commit ends " + actionTimestamp); tempActionHistory.add("transaction ends " + actionTimestamp);
tempActionHistory.clear(); tempActionHistory.clear();
//*/ //*/
} }
/** /**
* Clear structures and reset variables to original. For JDBC use only. * Clear structures and reset variables to original. For JDBC use only.
* Note: sets autocommit true * Note: sets autocommit true
*/ */
public synchronized void resetSession() { public synchronized void resetSession() {
skipping to change at line 1312 skipping to change at line 1312
try { try {
/* special autocommit for backward compatibility */ /* special autocommit for backward compatibility */
commit(false); commit(false);
} catch (HsqlException e) { } catch (HsqlException e) {
database.logger.logInfoEvent("Exception at commit"); database.logger.logInfoEvent("Exception at commit");
} }
} }
sessionContext.currentStatement = cs; sessionContext.currentStatement = cs;
sessionContext.invalidStatement = false;
statementStartSCN = database.txManager.getSystemChangeNumber(); statementStartSCN = database.txManager.getSystemChangeNumber();
boolean isTX = cs.isTransactionStatement(); boolean isTX = cs.isTransactionStatement();
if (!isTX) { if (!isTX) {
actionSCN = database.txManager.getNextSystemChangeNumber(); actionSCN = database.txManager.getNextSystemChangeNumber();
sessionContext.setDynamicArguments(pvals); sessionContext.setDynamicArguments(pvals);
// statements such as DISCONNECT may close the session // statements such as DISCONNECT may close the session
if (database.logger.getSqlEventLogLevel() if (database.logger.getSqlEventLogLevel()
>= SimpleLog.LOG_NORMAL) { >= SimpleLog.LOG_NORMAL) {
database.logger.logStatementEvent(this, cs, pvals, database.logger.logStatementEvent(this, cs, pvals,
Result.updateZeroResult, Result.updateZeroResult,
SimpleLog.LOG_NORMAL); SimpleLog.LOG_NORMAL);
} }
r = cs.execute(this); r = cs.execute(this);
sessionContext.currentStatement = null; sessionContext.currentStatement = null;
sessionContext.invalidStatement = false;
abortAction = false; abortAction = false;
sessionData.persistentStoreCollection.clearStatementTables(); sessionData.persistentStoreCollection.clearStatementTables();
return r; return r;
} }
timeoutManager.startTimeout(timeout); timeoutManager.startTimeout(timeout);
repeatLoop: repeatLoop:
skipping to change at line 1352 skipping to change at line 1354
actionIndex = rowActionList.size(); actionIndex = rowActionList.size();
database.txManager.beginAction(this, cs); database.txManager.beginAction(this, cs);
if (redoAction) { if (redoAction) {
redoAction = false; redoAction = false;
continue; continue;
} }
cs = sessionContext.currentStatement;
if (cs == null) {
return Result.newErrorResult(Error.error(ErrorCode.X_07502));
}
if (abortTransaction) { if (abortTransaction) {
return handleAbortTransaction(); return handleAbortTransaction();
} }
while (true) { while (true) {
try { try {
latch.await(); latch.await();
} catch (InterruptedException e) { } catch (InterruptedException e) {
if (txInterruptRollback) { if (txInterruptRollback) {
database.txManager.resetSession( database.txManager.resetSession(
skipping to change at line 1400 skipping to change at line 1396
} }
if (abortTransaction) { if (abortTransaction) {
Result result = handleAbortTransaction(); Result result = handleAbortTransaction();
return result; return result;
} }
database.txManager.beginActionResume(this); database.txManager.beginActionResume(this);
// tempActionHistory.add("sql execute " + cs.sql + " " + acti // expiration check
onTimestamp + " " + rowActionList.size()); cs = sessionContext.currentStatement;
sessionContext.setDynamicArguments(pvals);
r = cs.execute(this); if (sessionContext.invalidStatement) {
r = Result.newErrorResult(Error.error(ErrorCode.X_07502));
abortTransaction = true;
} else {
if (database.logger.getSqlEventLogLevel() // tempActionHistory.add("sql execute " + cs.sql + " " + actionT
>= SimpleLog.LOG_NORMAL) { imestamp + " " + rowActionList.size());
database.logger.logStatementEvent(this, cs, pvals, r, sessionContext.setDynamicArguments(pvals);
SimpleLog.LOG_NORMAL);
r = cs.execute(this);
// tempActionHistory.add("sql execute end " + actionTimestamp +
" " + rowActionList.size());
if (database.logger.getSqlEventLogLevel()
>= SimpleLog.LOG_NORMAL) {
database.logger.logStatementEvent(this, cs, pvals, r,
SimpleLog.LOG_NORMAL);
}
} }
// tempActionHistory.add("sql execute end " + actionTimestamp + " " + rowActionList.size());
endAction(r); endAction(r);
if (abortTransaction) { if (abortTransaction) {
break repeatLoop; break repeatLoop;
} }
if (redoAction) { if (redoAction) {
redoAction = false; redoAction = false;
while (true) { while (true) {
skipping to change at line 1461 skipping to change at line 1467
if (sessionContext.depth == 0) { if (sessionContext.depth == 0) {
if (sessionContext.isAutoCommit || cs.isAutoCommitStatement()) { if (sessionContext.isAutoCommit || cs.isAutoCommitStatement()) {
try { try {
if (r.mode == ResultConstants.ERROR) { if (r.mode == ResultConstants.ERROR) {
rollbackNoCheck(false); rollbackNoCheck(false);
} else { } else {
commit(false); commit(false);
} }
} catch (Exception e) { } catch (Exception e) {
sessionContext.currentStatement = null; sessionContext.currentStatement = null;
sessionContext.invalidStatement = false;
return Result.newErrorResult(Error.error(ErrorCode.X_40001, return Result.newErrorResult(Error.error(ErrorCode.X_40001,
e)); e));
} }
} else if (sessionContext.autoCommitRows > 0) { } else if (sessionContext.autoCommitRows > 0) {
if (rowActionList.size() > sessionContext.autoCommitRows) { if (rowActionList.size() > sessionContext.autoCommitRows) {
try { try {
commit(false); commit(false);
} catch (Exception e) { } catch (Exception e) {
sessionContext.currentStatement = null; sessionContext.currentStatement = null;
sessionContext.invalidStatement = false;
return Result.newErrorResult( return Result.newErrorResult(
Error.error(ErrorCode.X_40001, e)); Error.error(ErrorCode.X_40001, e));
} }
} }
} }
} }
sessionContext.currentStatement = null; sessionContext.currentStatement = null;
sessionContext.invalidStatement = false;
return r; return r;
} }
private Result handleAbortTransaction() { private Result handleAbortTransaction() {
rollbackNoCheck(false); rollbackNoCheck(false);
sessionContext.currentStatement = null; sessionContext.currentStatement = null;
sessionContext.invalidStatement = false;
return Result.newErrorResult(Error.error(ErrorCode.X_40001)); return Result.newErrorResult(Error.error(ErrorCode.X_40001));
} }
private Result executeCompiledBatchStatement(Result cmd) { private Result executeCompiledBatchStatement(Result cmd) {
long csid; long csid;
Statement cs; Statement cs;
int[] updateCounts; int[] updateCounts;
int count; int count;
 End of changes. 18 change blocks. 
22 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)