public void setDropAction(int dropAction) { this.dropAction = dropAction; if (next != null) { next.setDropAction(dropAction); } }
/** * 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); } }
public void setIfExists(boolean b) { ifExists = b; if (next != null) { next.setIfExists(b); } }
/** * Add a constraint statement to this statement. The primary key definition * is one possible constraint statement. * * @param command the statement to add */ public void addConstraintCommand(DefineCommand command) { if (command instanceof CreateIndex) { constraintCommands.add(command); } else { AlterTableAddConstraint con = (AlterTableAddConstraint) command; boolean alreadySet; if (con.getType() == CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY) { alreadySet = setPrimaryKeyColumns(con.getIndexColumns()); } else { alreadySet = false; } if (!alreadySet) { constraintCommands.add(command); } } }
private AlterTableAlterColumn parseAlterTableAlterColumnType(Table table, String columnName, Column column) { Column newColumn = parseColumnForTable(columnName, column.isNullable()); AlterTableAlterColumn command = new AlterTableAlterColumn(session, table.getSchema()); command.setTable(table); command.setType(CommandInterface.ALTER_TABLE_ALTER_COLUMN_CHANGE_TYPE); command.setOldColumn(column); command.setNewColumn(newColumn); return command; }
private CreateSchema parseCreateSchema() { CreateSchema command = new CreateSchema(session); command.setIfNotExists(readIfNotExists()); command.setSchemaName(readUniqueIdentifier()); if (readIf("AUTHORIZATION")) { command.setAuthorization(readUniqueIdentifier()); } else { command.setAuthorization(session.getUser().getName()); } return command; }
private CreateConstant parseCreateConstant() { boolean ifNotExists = readIfNotExists(); String constantName = readIdentifierWithSchema(); Schema schema = getSchema(); if (isKeyword(constantName)) { throw DbException.get(ErrorCode.CONSTANT_ALREADY_EXISTS_1, constantName); } read("VALUE"); Expression expr = readExpression(); CreateConstant command = new CreateConstant(session, schema); command.setConstantName(constantName); command.setExpression(expr); command.setIfNotExists(ifNotExists); return command; }
private CreateUserDataType parseCreateUserDataType() { boolean ifNotExists = readIfNotExists(); CreateUserDataType command = new CreateUserDataType(session); command.setTypeName(readUniqueIdentifier()); read("AS"); Column col = parseColumnForTable("VALUE", true); if (readIf("CHECK")) { Expression expr = readExpression(); col.addCheckConstraint(session, expr); } col.rename(null); command.setColumn(col); command.setIfNotExists(ifNotExists); return command; }
private CreateRole parseCreateRole() { CreateRole command = new CreateRole(session); command.setIfNotExists(readIfNotExists()); command.setRoleName(readUniqueIdentifier()); return command; }
private DropUserDataType parseDropUserDataType() { boolean ifExists = readIfExists(false); DropUserDataType command = new DropUserDataType(session); command.setTypeName(readUniqueIdentifier()); ifExists = readIfExists(ifExists); command.setIfExists(ifExists); return command; }
private DropAggregate parseDropAggregate() { boolean ifExists = readIfExists(false); DropAggregate command = new DropAggregate(session); command.setName(readUniqueIdentifier()); ifExists = readIfExists(ifExists); command.setIfExists(ifExists); return command; }
private AlterSchemaRename parseAlterSchema() { String schemaName = readIdentifierWithSchema(); Schema old = getSchema(); AlterSchemaRename command = new AlterSchemaRename(session); command.setOldSchema(getSchema(schemaName)); read("RENAME"); read("TO"); String newName = readIdentifierWithSchema(old.getName()); checkSchema(old); command.setNewName(newName); return command; }
private AlterIndexRename parseAlterIndex() { String indexName = readIdentifierWithSchema(); Schema old = getSchema(); AlterIndexRename command = new AlterIndexRename(session); command.setOldIndex(getSchema().getIndex(indexName)); read("RENAME"); read("TO"); String newName = readIdentifierWithSchema(old.getName()); checkSchema(old); command.setNewName(newName); return command; }
private Prepared parseTruncate() { read("TABLE"); Table table = readTableOrView(); TruncateTable command = new TruncateTable(session); command.setTable(table); return command; }
private void executeDrop(DropTable next) { String tableName = next.getTableName(); TableMate table = getTableMate(tableName); invokeUpdateWorker(dropWorkers.get(next)); table.markDeleted(); next = next.getNext(); if (next != null) { executeDrop(next); } }
private AlterView parseAlterView() { AlterView command = new AlterView(session); String viewName = readIdentifierWithSchema(); Table tableView = getSchema().findTableOrView(session, viewName); if (!(tableView instanceof TableView)) { throw DbException.get(ErrorCode.VIEW_NOT_FOUND_1, viewName); } TableView view = (TableView) tableView; command.setView(view); read("RECOMPILE"); return command; }
@Override public int doUpdate() { String tableName = prepared.getTableName(); TableMate tableMate = getTableMate(tableName); int affectRows = invokeUpdateWorker(workers); tableMate.loadMataData(session); return affectRows; }
@Override public int doUpdate() { String tableName = prepared.getTableName(); TableMate table = getTableMate(tableName); int affectRows = invokeUpdateWorker(workers); table.loadMataData(session); return affectRows; }
@Override public int doUpdate() { String tableName = prepared.getTableName(); TableMate table = getTableMate(tableName); int affectRows = invokeUpdateWorker(workers); table.loadMataData(session); return affectRows; }
@Override public int doUpdate() { TableMate table = getTableMate(prepared.getTable().getName()); int affectRows = invokeUpdateWorker(workers); table.loadMataData(session); return affectRows; }