Beispiel #1
0
 /**
  * Try to find a constraint with this name. This method returns null if no object with this name
  * exists.
  *
  * @param session the session
  * @param name the object name
  * @return the object or null
  */
 public Constraint findConstraint(ServerSession session, String name) {
   Constraint constraint = constraints.get(name);
   if (constraint == null) {
     constraint = session.findLocalTempTableConstraint(name);
   }
   return constraint;
 }
Beispiel #2
0
 /**
  * Try to find an index with this name. This method returns null if no object with this name
  * exists.
  *
  * @param session the session
  * @param name the object name
  * @return the object or null
  */
 public Index findIndex(ServerSession session, String name) {
   Index index = indexes.get(name);
   if (index == null) {
     index = session.findLocalTempTableIndex(name);
   }
   return index;
 }
Beispiel #3
0
 /**
  * Try to find a table or view with this name. This method returns null if no object with this
  * name exists. Local temporary tables are also returned.
  *
  * @param session the session
  * @param name the object name
  * @return the object or null
  */
 public Table findTableOrView(ServerSession session, String name) {
   Table table = tablesAndViews.get(name);
   if (table == null && session != null) {
     table = session.findLocalTempTable(name);
   }
   return table;
 }
Beispiel #4
0
 /**
  * Flush the current value, including the margin, to disk.
  *
  * @param session the session
  */
 public void flush(ServerSession session, long flushValueWithMargin) {
   if (session == null || !database.isSysTableLockedBy(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.
     ServerSession sysSession = database.getSystemSession();
     synchronized (sysSession) {
       flushInternal(sysSession, flushValueWithMargin);
       sysSession.commit(false);
     }
   } else {
     synchronized (session) {
       flushInternal(session, flushValueWithMargin);
     }
   }
 }
Beispiel #5
0
 /**
  * Create a unique index name.
  *
  * @param session the session
  * @param table the indexed table
  * @param prefix the index name prefix
  * @return the unique name
  */
 public String getUniqueIndexName(ServerSession session, Table table, String prefix) {
   HashMap<String, Index> tableIndexes;
   if (table.isTemporary() && !table.isGlobalTemporary()) {
     tableIndexes = session.getLocalTempTableIndexes();
   } else {
     tableIndexes = indexes;
   }
   return getUniqueName(table, tableIndexes, prefix);
 }
Beispiel #6
0
 /**
  * Create a unique constraint name.
  *
  * @param session the session
  * @param table the constraint table
  * @return the unique name
  */
 public String getUniqueConstraintName(ServerSession session, Table table) {
   HashMap<String, Constraint> tableConstraints;
   if (table.isTemporary() && !table.isGlobalTemporary()) {
     tableConstraints = session.getLocalTempTableConstraints();
   } else {
     tableConstraints = constraints;
   }
   return getUniqueName(table, tableConstraints, "CONSTRAINT_");
 }
Beispiel #7
0
 /**
  * Get the table or view with the given name. Local temporary tables are also returned.
  *
  * @param session the session
  * @param name the table or view name
  * @return the table or view
  * @throws DbException if no such object exists
  */
 public Table getTableOrView(ServerSession session, String name) {
   Table table = tablesAndViews.get(name);
   if (table == null) {
     if (session != null) {
       table = session.findLocalTempTable(name);
     }
     if (table == null) {
       throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, name);
     }
   }
   return table;
 }