private void checkRights() { if (insertCommand != null) { session.getUser().checkRight(targetTable, Right.INSERT); } if (updateCommand != null) { session.getUser().checkRight(targetTable, Right.UPDATE); } if (deleteCommand != null) { session.getUser().checkRight(targetTable, Right.DELETE); } // check the underlying tables session.getUser().checkRight(targetTable, Right.SELECT); session.getUser().checkRight(sourceTableFilter.getTable(), Right.SELECT); }
@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; }
/** * Create a new table filter object. * * @param session the session * @param table the table from where to read data * @param alias the alias name * @param rightsChecked true if rights are already checked * @param select the select statement * @param orderInFrom original order number (index) of this table filter in * @param indexHints the index hints to be used by the query planner */ public TableFilter(Session session, Table table, String alias, boolean rightsChecked, Select select, int orderInFrom, IndexHints indexHints) { this.session = session; this.table = table; this.alias = alias; this.select = select; this.cursor = new IndexCursor(this); if (!rightsChecked) { session.getUser().checkRight(table, Right.SELECT); } hashCode = session.nextObjectId(); this.orderInFrom = orderInFrom; this.indexHints = indexHints; }
@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; }
@Override public int update() { session.commit(true); Constraint constraint = getSchema().findConstraint(session, constraintName); if (constraint == null) { throw DbException.get(ErrorCode.CONSTRAINT_NOT_FOUND_1, constraintName); } if (getSchema().findConstraint(session, newConstraintName) != null || newConstraintName.equals(constraintName)) { throw DbException.get(ErrorCode.CONSTRAINT_ALREADY_EXISTS_1, newConstraintName); } session.getUser().checkRight(constraint.getTable(), Right.ALL); session.getUser().checkRight(constraint.getRefTable(), Right.ALL); session.getDatabase().renameSchemaObject(session, constraint, newConstraintName); return 0; }
@Override public int update() { session.commit(true); if (!table.canTruncate()) { throw DbException.get(ErrorCode.CANNOT_TRUNCATE_1, table.getSQL()); } session.getUser().checkRight(table, Right.DELETE); table.lock(session, true, true); table.truncate(session); return 0; }
@Override public int update() { session.commit(true); Database db = session.getDatabase(); oldIndex = oldSchema.findIndex(session, oldIndexName); if (oldIndex == null) { if (!ifExists) { throw DbException.get(ErrorCode.INDEX_NOT_FOUND_1, newIndexName); } return 0; } if (oldSchema.findIndex(session, newIndexName) != null || newIndexName.equals(oldIndexName)) { throw DbException.get(ErrorCode.INDEX_ALREADY_EXISTS_1, newIndexName); } session.getUser().checkRight(oldIndex.getTable(), Right.ALL); db.renameSchemaObject(session, oldIndex, newIndexName); return 0; }
@Override public int update() { Table table = getSchema().resolveTableOrView(session, tableName); if (table == null) { if (ifTableExists) { return 0; } throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName); } session.getUser().checkRight(table, Right.ALL); table.lock(session, true, true); switch (type) { case CommandInterface.ALTER_TABLE_SET_REFERENTIAL_INTEGRITY: table.setCheckForeignKeyConstraints(session, value, value ? checkExisting : false); break; default: DbException.throwInternalError("type="+type); } return 0; }
@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; }
@Override public int update() { session.commit(true); Database db = session.getDatabase(); Table oldTable = getSchema().findTableOrView(session, oldTableName); if (oldTable == null) { if (ifTableExists) { return 0; } throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, oldTableName); } session.getUser().checkRight(oldTable, Right.ALL); Table t = getSchema().findTableOrView(session, newTableName); if (t != null && hidden && newTableName.equals(oldTable.getName())) { if (!t.isHidden()) { t.setHidden(hidden); oldTable.setHidden(true); db.updateMeta(session, oldTable); } return 0; } if (t != null || newTableName.equals(oldTable.getName())) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, newTableName); } if (oldTable.isTemporary()) { throw DbException.getUnsupportedException("temp table"); } db.renameSchemaObject(session, oldTable, newTableName); return 0; }
session.getUser().checkRight(index.getTable(), Right.ALL); Constraint pkConstraint = null; ArrayList<Constraint> constraints = table.getConstraints();
@Override public int update() { int count; session.getUser().checkRight(table, Right.INSERT); session.getUser().checkRight(table, Right.UPDATE); setCurrentRowNumber(0); if (!list.isEmpty()) {
@Override public int update() { int count; session.getUser().checkRight(targetTable, Right.INSERT); session.getUser().checkRight(targetTable, Right.UPDATE); setCurrentRowNumber(0); GeneratedKeys generatedKeys = session.getGeneratedKeys();
throw DbException.get(ErrorCode.VIEW_NOT_FOUND_1, viewName); session.getUser().checkRight(view, Right.ALL);
session.getUser().checkRight(table, Right.ALL);
@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; }
session.getUser().checkRight(table, Right.ALL); if (!table.canDrop()) { throw DbException.get(ErrorCode.CANNOT_DROP_TABLE_1, tableName);
private int insertRows() { session.getUser().checkRight(table, Right.INSERT); setCurrentRowNumber(0); table.fire(session, Trigger.INSERT, true);
session.getUser().checkRight(table, Right.ALL); table.lock(session, true, true); if (!table.isPersistIndexes()) {
targetTableFilter.reset(); Table table = targetTableFilter.getTable(); session.getUser().checkRight(table, Right.DELETE); table.fire(session, Trigger.DELETE, true); table.lock(session, true, false);