use of org.h2.command.dml.Update in project h2database by h2database.
the class AlterTableRenameColumn method update.
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
Table table = getSchema().findTableOrView(session, tableName);
if (table == null) {
if (ifTableExists) {
return 0;
}
throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName);
}
Column column = table.getColumn(oldName);
session.getUser().checkRight(table, Right.ALL);
table.checkSupportAlter();
// we need to update CHECK constraint
// since it might reference the name of the column
Expression newCheckExpr = column.getCheckConstraint(session, newName);
table.renameColumn(column, newName);
column.removeCheckConstraint();
column.addCheckConstraint(session, newCheckExpr);
table.setModified();
db.updateMeta(session, table);
for (DbObject child : table.getChildren()) {
if (child.getCreateSQL() != null) {
db.updateMeta(session, child);
}
}
return 0;
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class CreateFunctionAlias method update.
@Override
public int update() {
session.commit(true);
session.getUser().checkAdmin();
Database db = session.getDatabase();
if (getSchema().findFunction(aliasName) != null) {
if (!ifNotExists) {
throw DbException.get(ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, aliasName);
}
} else {
int id = getObjectId();
FunctionAlias functionAlias;
if (javaClassMethod != null) {
functionAlias = FunctionAlias.newInstance(getSchema(), id, aliasName, javaClassMethod, force, bufferResultSetToLocalTemp);
} else {
functionAlias = FunctionAlias.newInstanceFromSource(getSchema(), id, aliasName, source, force, bufferResultSetToLocalTemp);
}
functionAlias.setDeterministic(deterministic);
db.addSchemaObject(session, functionAlias);
}
return 0;
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class CreateLinkedTable method update.
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
session.getUser().checkAdmin();
if (getSchema().resolveTableOrView(session, tableName) != null) {
if (ifNotExists) {
return 0;
}
throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, tableName);
}
int id = getObjectId();
TableLink table = getSchema().createTableLink(id, tableName, driver, url, user, password, originalSchema, originalTable, emitUpdates, force);
table.setTemporary(temporary);
table.setGlobalTemporary(globalTemporary);
table.setComment(comment);
table.setReadOnly(readOnly);
if (temporary && !globalTemporary) {
session.addLocalTempTable(table);
} else {
db.addSchemaObject(session, table);
}
return 0;
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class AlterView method update.
@Override
public int update() {
session.commit(true);
if (view == null && ifExists) {
return 0;
}
session.getUser().checkRight(view, Right.ALL);
DbException e = view.recompile(session, false, true);
if (e != null) {
throw e;
}
return 0;
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class ExecuteProcedure method update.
@Override
public int update() {
setParameters();
Prepared prepared = procedure.getPrepared();
return prepared.update();
}
Aggregations