Exemplo n.º 1
0
 /**
  * Commit or roll back the given transaction.
  *
  * @param transactionName the name of the transaction
  * @param commit true for commit, false for rollback
  */
 public void setPreparedTransaction(String transactionName, boolean commit) {
   if (currentTransactionName != null && currentTransactionName.equals(transactionName)) {
     if (commit) {
       commit(false);
     } else {
       rollback();
     }
   } else {
     ArrayList<InDoubtTransaction> list = database.getInDoubtTransactions();
     int state = commit ? InDoubtTransaction.COMMIT : InDoubtTransaction.ROLLBACK;
     boolean found = false;
     if (list != null) {
       for (InDoubtTransaction p : list) {
         if (p.getTransactionName().equals(transactionName)) {
           p.setState(state);
           found = true;
           break;
         }
       }
     }
     if (!found) {
       throw DbException.get(ErrorCode.TRANSACTION_NOT_FOUND_1, transactionName);
     }
   }
 }
Exemplo n.º 2
0
 /**
  * Flush the current value, including the margin, to disk.
  *
  * @param session the session
  */
 public synchronized void flush(Session session) {
   if (session == null || !database.isSysTableLocked()) {
     // This session may not lock the sys table (except if it already has locked it)
     // because it must be committed immediately,
     // otherwise other threads can not access the sys table.
     Session sysSession = database.getSystemSession();
     synchronized (sysSession) {
       flushInternal(sysSession);
       sysSession.commit(false);
     }
   } else {
     synchronized (session) {
       flushInternal(session);
     }
   }
 }
Exemplo n.º 3
0
 private void dropTable() {
   if (table == null) {
     return;
   }
   if (containsLob) {
     // contains BLOB or CLOB: can not truncate now,
     // otherwise the BLOB and CLOB entries are removed
     return;
   }
   try {
     Database database = session.getDatabase();
     // Need to lock because not all of the code-paths
     // that reach here have already taken this lock,
     // notably via the close() paths.
     synchronized (session) {
       synchronized (database) {
         table.truncate(session);
       }
     }
     // This session may not lock the sys table (except if it already has
     // locked it) because it must be committed immediately, otherwise
     // other threads can not access the sys table. If the table is not
     // removed now, it will be when the database is opened the next
     // time. (the table is truncated, so this is just one record)
     if (!database.isSysTableLocked()) {
       Session sysSession = database.getSystemSession();
       table.removeChildrenAndResources(sysSession);
       if (index != null) {
         // need to explicitly do this,
         // as it's not registered in the system session
         session.removeLocalTempTableIndex(index);
       }
       // the transaction must be committed immediately
       // TODO this synchronization cascade is very ugly
       synchronized (session) {
         synchronized (sysSession) {
           synchronized (database) {
             sysSession.commit(false);
           }
         }
       }
     }
   } finally {
     table = null;
   }
 }