"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hsqldb/src/org/hsqldb/TransactionManagerMVCC.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.

TransactionManagerMVCC.java  (hsqldb-2.7.1):TransactionManagerMVCC.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 43 skipping to change at line 43
import org.hsqldb.error.Error; import org.hsqldb.error.Error;
import org.hsqldb.error.ErrorCode; import org.hsqldb.error.ErrorCode;
import org.hsqldb.lib.HsqlDeque; import org.hsqldb.lib.HsqlDeque;
import org.hsqldb.lib.LongDeque; import org.hsqldb.lib.LongDeque;
import org.hsqldb.persist.PersistentStore; import org.hsqldb.persist.PersistentStore;
/** /**
* Manages rows involved in transactions * Manages rows involved in transactions
* *
* @author Fred Toussi (fredt@users dot sourceforge.net) * @author Fred Toussi (fredt@users dot sourceforge.net)
* @version 2.7.0 * @version 2.7.2
* @since 2.0.0 * @since 2.0.0
*/ */
public class TransactionManagerMVCC extends TransactionManagerCommon public class TransactionManagerMVCC extends TransactionManagerCommon
implements TransactionManager { implements TransactionManager {
// functional unit - merged committed transactions // functional unit - merged committed transactions
HsqlDeque committedTransactions = new HsqlDeque(); HsqlDeque committedTransactions = new HsqlDeque();
LongDeque committedTransactionSCNs = new LongDeque(); LongDeque committedTransactionSCNs = new LongDeque();
// locks // locks
skipping to change at line 221 skipping to change at line 221
} else { } else {
if (session.rowActionList.size() > 0) { if (session.rowActionList.size() > 0) {
Object[] list = session.rowActionList.toArray(); Object[] list = session.rowActionList.toArray();
addToCommittedQueue(session, list); addToCommittedQueue(session, list);
} }
} }
endTransactionTPL(session); endTransactionTPL(session);
//
session.isTransaction = false; session.isTransaction = false;
countDownLatches(session); countDownLatches(session);
} finally { } finally {
session.actionSet.clear(); session.actionSet.clear();
writeLock.unlock(); writeLock.unlock();
} }
return true; return true;
} }
skipping to change at line 668 skipping to change at line 667
writeLock.lock(); writeLock.lock();
try { try {
if (hasExpired) { if (hasExpired) {
session.redoAction = true; session.redoAction = true;
return; return;
} }
cs = updateCurrentStatement(session, cs);
if (cs == null) {
return;
}
if (session.abortTransaction) { if (session.abortTransaction) {
return; return;
} }
session.isPreTransaction = true; session.isPreTransaction = true;
if (!isLockedMode && !cs.isCatalogLock(txModel)) { if (!isLockedMode && !cs.isCatalogLock(txModel)) {
return; return;
} }
skipping to change at line 698 skipping to change at line 691
} }
/** /**
* add session to the end of queue when a transaction starts * add session to the end of queue when a transaction starts
*/ */
public void beginActionResume(Session session) { public void beginActionResume(Session session) {
writeLock.lock(); writeLock.lock();
try { try {
Statement cs = session.sessionContext.currentStatement;
cs = updateCurrentStatement(session, cs);
if (session.sessionContext.invalidStatement) {
return;
}
if (session.isTransaction) { if (session.isTransaction) {
session.actionSCN = getNextSystemChangeNumber(); session.actionSCN = getNextSystemChangeNumber();
session.actionStartSCN = session.actionSCN; session.actionStartSCN = session.actionSCN;
} else { } else {
beginTransactionCommon(session); beginTransactionCommon(session);
liveTransactionSCNs.addLast(session.transactionSCN); liveTransactionSCNs.addLast(session.transactionSCN);
} }
} finally { } finally {
writeLock.unlock(); writeLock.unlock();
} }
skipping to change at line 749 skipping to change at line 749
session.waitedSessions.clear(); session.waitedSessions.clear();
session.waitingSessions.clear(); session.waitingSessions.clear();
} }
void endTransactionTPL(Session session) { void endTransactionTPL(Session session) {
if (catalogWriteSession != session) { if (catalogWriteSession != session) {
return; return;
} }
//
Session nextSession = null; Session nextSession = null;
for (int i = 0; i < session.waitingSessions.size(); i++) { for (int i = 0; i < session.waitingSessions.size(); i++) {
Session current = (Session) session.waitingSessions.get(i); Session current = (Session) session.waitingSessions.get(i);
Statement st = current.sessionContext.currentStatement; Statement st = current.sessionContext.currentStatement;
if (st != null && st.isCatalogLock(txModel)) { if (st != null && st.isCatalogLock(txModel)) {
nextSession = current; nextSession = current;
break; break;
skipping to change at line 784 skipping to change at line 783
} }
} }
catalogWriteSession = nextSession; catalogWriteSession = nextSession;
} }
unlockTxTs = session.actionSCN; unlockTxTs = session.actionSCN;
unlockSessionId = session.getId(); unlockSessionId = session.getId();
} }
boolean beginActionTPL(Session session, Statement cs) { void beginActionTPL(Session session, Statement cs) {
if (session == catalogWriteSession) { if (session == catalogWriteSession) {
return true; return;
} }
session.tempSet.clear(); session.tempSet.clear();
if (cs.isCatalogLock(txModel)) { if (cs.isCatalogLock(txModel)) {
if (catalogWriteSession == null) { if (!isLockedMode) {
catalogWriteSession = session; catalogWriteSession = session;
isLockedMode = true; isLockedMode = true;
lockTxTs = session.actionSCN; lockTxTs = session.actionSCN;
lockSessionId = session.getId(); lockSessionId = session.getId();
getTransactionAndPreSessions(session); getTransactionAndPreSessions(session);
if (!session.tempSet.isEmpty()) { if (!session.tempSet.isEmpty()) {
session.waitedSessions.addAll(session.tempSet); session.waitedSessions.addAll(session.tempSet);
setWaitingSessionTPL(session); setWaitingSessionTPL(session);
} }
return true; return;
} }
} }
if (!isLockedMode) { if (!isLockedMode) {
return true; return;
} }
if (cs.getTableNamesForWrite().length > 0) { if (cs.getTableNamesForWrite().length > 0) {
if (cs.getTableNamesForWrite()[0].schema if (cs.getTableNamesForWrite()[0].schema
== SqlInvariants.LOBS_SCHEMA_HSQLNAME) { == SqlInvariants.LOBS_SCHEMA_HSQLNAME) {
return true; return;
} }
} else if (cs.getTableNamesForRead().length > 0) { } else if (cs.getTableNamesForRead().length > 0) {
if (cs.getTableNamesForRead()[0].schema if (cs.getTableNamesForRead()[0].schema
== SqlInvariants.LOBS_SCHEMA_HSQLNAME) { == SqlInvariants.LOBS_SCHEMA_HSQLNAME) {
return true; return;
} }
} }
if (session.waitingSessions.contains(catalogWriteSession)) { if (session.waitingSessions.contains(catalogWriteSession)) {
return true; return;
} }
if (catalogWriteSession.waitingSessions.add(session)) { if (catalogWriteSession.waitingSessions.add(session)) {
session.waitedSessions.add(catalogWriteSession); session.waitedSessions.add(catalogWriteSession);
session.latch.setCount(session.waitedSessions.size()); session.latch.setCount(session.waitedSessions.size());
} }
return true;
} }
public void resetSession(Session session, Session targetSession, public void resetSession(Session session, Session targetSession,
long statementTimestamp, int mode) { long statementTimestamp, int mode) {
super.resetSession(session, targetSession, statementTimestamp, mode); super.resetSession(session, targetSession, statementTimestamp, mode);
} }
} }
 End of changes. 15 change blocks. 
20 lines changed or deleted 17 lines changed or added

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