while (triggers != null && triggers.size() > 0) { TriggerObject obj = (TriggerObject) triggers.values().toArray()[0]; database.removeSchemaObject(session, obj); database.removeSchemaObject(session, obj); database.removeSchemaObject(session, obj); } else { runLoopAgain = true; while (indexes != null && indexes.size() > 0) { Index obj = (Index) indexes.values().toArray()[0]; database.removeSchemaObject(session, obj); database.removeSchemaObject(session, obj); database.removeSchemaObject(session, obj); database.removeSchemaObject(session, obj);
TableView view = dependentViews.get(0); dependentViews.remove(0); database.removeSchemaObject(session, view); database.removeSchemaObject(session, synonym); database.removeSchemaObject(session, trigger); database.removeSchemaObject(session, constraint); database.removeSchemaObject(session, sequence);
private void removeSequence(Table table, Sequence sequence) { if (sequence != null) { table.removeSequence(sequence); sequence.setBelongsToTable(false); Database db = session.getDatabase(); db.removeSchemaObject(session, sequence); } }
/** * If the index is still required by a constraint, transfer the ownership to * it. Otherwise, the index is removed. * * @param session the session * @param index the index that is no longer required */ public void removeIndexOrTransferOwnership(Session session, Index index) { boolean stillNeeded = false; if (constraints != null) { for (Constraint cons : constraints) { if (cons.usesIndex(index)) { cons.setIndexOwner(index); database.updateMeta(session, cons); stillNeeded = true; } } } if (!stillNeeded) { database.removeSchemaObject(session, index); } }
@Override public int update() { try { return tryUpdate(); } catch (DbException e) { for (Index index : createdIndexes) { session.getDatabase().removeSchemaObject(session, index); } throw e; } finally { getSchema().freeUniqueName(constraintName); } }
/** * Remove the given index from the list. * * @param h2Idx the index to remove */ public void removeIndex(Session session, Index h2Idx) { lock(true); try { ArrayList<Index> idxs = new ArrayList<>(this.idxs); Index targetIdx = (h2Idx instanceof GridH2ProxyIndex) ? ((GridH2ProxyIndex)h2Idx).underlyingIndex() : h2Idx; for (int i = pkIndexPos; i < idxs.size();) { Index idx = idxs.get(i); if (idx == targetIdx || (idx instanceof GridH2ProxyIndex && ((GridH2ProxyIndex)idx).underlyingIndex() == targetIdx)) { idxs.remove(i); if (idx instanceof GridH2ProxyIndex && idx.getSchema().findIndex(session, idx.getName()) != null) database.removeSchemaObject(session, idx); continue; } i++; } this.idxs = idxs; } finally { unlock(true); } }
private void executeDrop() { // need to get the table again, because it may be dropped already // meanwhile (dependent object, or same object) table = getSchema().findTableOrView(session, tableName); if (table != null) { table.setModified(); Database db = session.getDatabase(); db.lockMeta(session); db.removeSchemaObject(session, table); } if (next != null) { next.executeDrop(); } }
/** * Remove a table for a recursive query. * * @param isPersistent whether the table is persisted * @param targetSession the session * @param recursiveTable the table */ public static void destroyShadowTableForRecursiveExpression(boolean isPersistent, Session targetSession, Table recursiveTable) { if (recursiveTable != null) { if (isPersistent) { recursiveTable.lock(targetSession, true, true); targetSession.getDatabase().removeSchemaObject(targetSession, recursiveTable); } else { targetSession.removeLocalTempTable(recursiveTable); } // both removeSchemaObject and removeLocalTempTable hold meta locks - release them here targetSession.getDatabase().unlockMeta(targetSession); } } }
@Override public int update() { session.commit(true); session.getUser().checkAdmin(); TableSynonym synonym = getSchema().getSynonym(synonymName); if (synonym == null) { if (!ifExists) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, synonymName); } } else { session.getDatabase().removeSchemaObject(session, synonym); } return 0; }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); FunctionAlias functionAlias = getSchema().findFunction(aliasName); if (functionAlias == null) { if (!ifExists) { throw DbException.get(ErrorCode.FUNCTION_ALIAS_NOT_FOUND_1, aliasName); } } else { db.removeSchemaObject(session, functionAlias); } return 0; }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); Constant constant = getSchema().findConstant(constantName); if (constant == null) { if (!ifExists) { throw DbException.get(ErrorCode.CONSTANT_NOT_FOUND_1, constantName); } } else { db.removeSchemaObject(session, constant); } return 0; }
db.removeSchemaObject(session, pkConstraint); } else { db.removeSchemaObject(session, index);
@Override public int update() { session.commit(true); Database db = session.getDatabase(); TriggerObject trigger = getSchema().findTrigger(triggerName); if (trigger == null) { if (!ifExists) { throw DbException.get(ErrorCode.TRIGGER_NOT_FOUND_1, triggerName); } } else { Table table = trigger.getTable(); session.getUser().checkRight(table, Right.ALL); db.removeSchemaObject(session, trigger); } return 0; }
Index index = indexes.get(1); if (index.getName() != null) { database.removeSchemaObject(session, index);
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); Sequence sequence = getSchema().findSequence(sequenceName); if (sequence == null) { if (!ifExists) { throw DbException.get(ErrorCode.SEQUENCE_NOT_FOUND_1, sequenceName); } } else { if (sequence.getBelongsToTable()) { throw DbException.get(ErrorCode.SEQUENCE_BELONGS_TO_A_TABLE_1, sequenceName); } db.removeSchemaObject(session, sequence); } return 0; }
Index index = indexes.get(1); if (index.getName() != null) { database.removeSchemaObject(session, index);
@Override public int update() { session.commit(true); Constraint constraint = getSchema().findConstraint(session, constraintName); if (constraint == null) { if (!ifExists) { throw DbException.get(ErrorCode.CONSTRAINT_NOT_FOUND_1, constraintName); } } else { session.getUser().checkRight(constraint.getTable(), Right.ALL); session.getUser().checkRight(constraint.getRefTable(), Right.ALL); session.getDatabase().removeSchemaObject(session, constraint); } return 0; }
/** {@inheritDoc} */ @Override public void removeChildrenAndResources(Session ses) { lock(true); try { super.removeChildrenAndResources(ses); // Clear all user indexes registered in schema. while (idxs.size() > sysIdxsCnt) { Index idx = idxs.get(sysIdxsCnt); if (idx.getName() != null && idx.getSchema().findIndex(ses, idx.getName()) == idx) { // This call implicitly removes both idx and its proxy, if any, from idxs. database.removeSchemaObject(ses, idx); // We have to call destroy here if we are who has removed this index from the table. if (idx instanceof GridH2IndexBase) ((GridH2IndexBase)idx).destroy(rmIndex); } } if (SysProperties.CHECK) { for (SchemaObject obj : database.getAllSchemaObjects(DbObject.INDEX)) { Index idx = (Index) obj; if (idx.getTable() == this) DbException.throwInternalError("index not dropped: " + idx.getName()); } } database.removeMeta(ses, getId()); invalidate(); } finally { unlock(true); } }
session.getDatabase().removeSchemaObject(session, view); TableView childTableView = (TableView) childTable; if (childTableView.isTableExpression() && childTableView.getName() != null) { session.getDatabase().removeSchemaObject(session, childTableView);
db.addSchemaObject(targetSession, view); view.lock(targetSession, true, true); targetSession.getDatabase().removeSchemaObject(targetSession, view); } else { session.removeLocalTempTable(view);