/** * Chain another drop table statement to this statement. * * @param drop the statement to add */ public void addNextDropTable(DropTable drop) { if (next == null) { next = drop; } else { next.addNextDropTable(drop); } }
@Override public int update() { session.commit(true); prepareDrop(); executeDrop(); return 0; }
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(); } }
boolean ifExists = readIfExists(false); String tableName = readIdentifierWithSchema(); DropTable command = new DropTable(session, getSchema()); command.setTableName(tableName); while (readIf(",")) { tableName = readIdentifierWithSchema(); DropTable next = new DropTable(session, getSchema()); next.setTableName(tableName); command.addNextDropTable(next); command.setIfExists(ifExists); if (readIf("CASCADE")) { command.setDropAction(ConstraintActionType.CASCADE); readIf("CONSTRAINTS"); } else if (readIf("RESTRICT")) { command.setDropAction(ConstraintActionType.RESTRICT); } else if (readIf("IGNORE")) { command.setDropAction(ConstraintActionType.SET_DEFAULT);
private void prepareDrop() { table = getSchema().findTableOrView(session, tableName); if (table == null) { if (!ifExists) { next.prepareDrop();
public void setIfExists(boolean b) { ifExists = b; if (next != null) { next.setIfExists(b); } }
public void setDropAction(ConstraintActionType dropAction) { this.dropAction = dropAction; if (next != null) { next.setDropAction(dropAction); } }
boolean ifExists = readIfExists(false); String tableName = readIdentifierWithSchema(); DropTable command = new DropTable(session, getSchema()); command.setTableName(tableName); while (readIf(",")) { tableName = readIdentifierWithSchema(); DropTable next = new DropTable(session, getSchema()); next.setTableName(tableName); command.addNextDropTable(next); command.setIfExists(ifExists); if (readIf("CASCADE")) { command.setDropAction(ConstraintReferential.CASCADE); readIf("CONSTRAINTS"); } else if (readIf("RESTRICT")) { command.setDropAction(ConstraintReferential.RESTRICT); } else if (readIf("IGNORE")) { command.setDropAction(ConstraintReferential.SET_DEFAULT);
private void prepareDrop() throws SQLException { table = getSchema().findTableOrView(session, tableName); // TODO drop table: drops views as well (is this ok?) if (table == null) { if (!ifExists) { throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName); } } else { session.getUser().checkRight(table, Right.ALL); if (!table.canDrop()) { throw Message.getSQLException(ErrorCode.CANNOT_DROP_TABLE_1, tableName); } table.lock(session, true, true); } if (next != null) { next.prepareDrop(); } }
public void setIfExists(boolean b) { ifExists = b; if (next != null) { next.setIfExists(b); } }
public void setDropAction(int dropAction) { this.dropAction = dropAction; if (next != null) { next.setDropAction(dropAction); } }
boolean ifExists = readIfExists(false); String tableName = readIdentifierWithSchema(); DropTable command = new DropTable(session, getSchema()); command.setTableName(tableName); while (readIf(",")) { tableName = readIdentifierWithSchema(); DropTable next = new DropTable(session, getSchema()); next.setTableName(tableName); command.addNextDropTable(next); command.setIfExists(ifExists); if (readIf("CASCADE")) { command.setDropAction(ConstraintReferential.CASCADE); readIf("CONSTRAINTS"); } else if (readIf("RESTRICT")) { command.setDropAction(ConstraintReferential.RESTRICT); } else if (readIf("IGNORE")) { command.setDropAction(ConstraintReferential.SET_DEFAULT);
@Override public int update() { session.commit(true); prepareDrop(); executeDrop(); return 0; }
private void executeDrop() throws SQLException { // 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.removeSchemaObject(session, table); } if (next != null) { next.executeDrop(); } }
private void prepareDrop() { table = getSchema().findTableOrView(session, tableName); if (table == null) { if (!ifExists) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName); } } else { session.getUser().checkRight(table, Right.ALL); if (!table.canDrop()) { throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName); } if (dropAction == ConstraintReferential.RESTRICT) { ArrayList<TableView> views = table.getViews(); if (views != null && views.size() > 0) { StatementBuilder buff = new StatementBuilder(); for (TableView v : views) { buff.appendExceptFirst(", "); buff.append(v.getName()); } throw DbException.get(ErrorCode.CANNOT_DROP_2, tableName, buff.toString()); } } table.lock(session, true, true); } if (next != null) { next.prepareDrop(); } }
/** * Chain another drop table statement to this statement. * * @param next the statement to add */ public void addNextDropTable(DropTable next) { if (this.next == null) { this.next = next; } else { this.next.addNextDropTable(next); } }
public void setIfExists(boolean b) { ifExists = b; if (next != null) { next.setIfExists(b); } }
public void setDropAction(int dropAction) { this.dropAction = dropAction; if (next != null) { next.setDropAction(dropAction); } }
boolean ifExists = readIfExists(false); String tableName = readIdentifierWithSchema(); DropTable command = new DropTable(session, getSchema()); command.setTableName(tableName); while (readIf(",")) { tableName = readIdentifierWithSchema(); DropTable next = new DropTable(session, getSchema()); next.setTableName(tableName); command.addNextDropTable(next); command.setIfExists(ifExists); if (readIf("CASCADE")) { readIf("CONSTRAINTS");
public int update() throws SQLException { session.commit(true); prepareDrop(); executeDrop(); return 0; }