Exemplo n.º 1
0
 /**
  * Undo all operations back to the log position of the given savepoint.
  *
  * @param name the savepoint name
  */
 public void rollbackToSavepoint(String name) {
   checkCommitRollback();
   if (savepoints == null) {
     throw DbException.get(ErrorCode.SAVEPOINT_IS_INVALID_1, name);
   }
   Integer savepointIndex = savepoints.get(name);
   if (savepointIndex == null) {
     throw DbException.get(ErrorCode.SAVEPOINT_IS_INVALID_1, name);
   }
   int i = savepointIndex.intValue();
   rollbackTo(i, false);
 }
Exemplo n.º 2
0
 /**
  * Commit the current transaction. If the statement was not a data definition statement, and if
  * there are temporary tables that should be dropped or truncated at commit, this is done as well.
  *
  * @param ddl if the statement was a data definition statement
  */
 public void commit(boolean ddl) {
   checkCommitRollback();
   currentTransactionName = null;
   transactionStart = 0;
   if (containsUncommitted()) {
     // need to commit even if rollback is not possible
     // (create/drop table and so on)
     database.commit(this);
   }
   if (undoLog.size() > 0) {
     // commit the rows when using MVCC
     if (database.isMultiVersion()) {
       ArrayList<Row> rows = New.arrayList();
       synchronized (database) {
         while (undoLog.size() > 0) {
           UndoLogRecord entry = undoLog.getLast();
           entry.commit();
           rows.add(entry.getRow());
           undoLog.removeLast(false);
         }
         for (int i = 0, size = rows.size(); i < size; i++) {
           Row r = rows.get(i);
           r.commit();
         }
       }
     }
     undoLog.clear();
   }
   if (!ddl) {
     // do not clean the temp tables if the last command was a
     // create/drop
     cleanTempTables(false);
     if (autoCommitAtTransactionEnd) {
       autoCommit = true;
       autoCommitAtTransactionEnd = false;
     }
   }
   if (unlinkLobMap != null && unlinkLobMap.size() > 0) {
     // need to flush the transaction log, because we can't unlink lobs if the
     // commit record is not written
     database.flush();
     for (Value v : unlinkLobMap.values()) {
       v.unlink();
       v.close();
     }
     unlinkLobMap = null;
   }
   unlockAll();
 }
Exemplo n.º 3
0
 /** Fully roll back the current transaction. */
 public void rollback() {
   checkCommitRollback();
   currentTransactionName = null;
   boolean needCommit = false;
   if (undoLog.size() > 0) {
     rollbackTo(0, false);
     needCommit = true;
   }
   if (locks.size() > 0 || needCommit) {
     database.commit(this);
   }
   cleanTempTables(false);
   unlockAll();
   if (autoCommitAtTransactionEnd) {
     autoCommit = true;
     autoCommitAtTransactionEnd = false;
   }
 }