Example #1
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;
   }
 }