@Override public int update() { String name = fileNameExpr.getValue(session).getString(); session.getUser().checkAdmin(); backupTo(name); return 0; }
@Override public int update() { session.getUser().checkAdmin(); int count = 0; try {
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); if (roleName.equals(Constants.PUBLIC_ROLE_NAME)) { throw DbException.get(ErrorCode.ROLE_CAN_NOT_BE_DROPPED_1, roleName); } Role role = db.findRole(roleName); if (role == null) { if (!ifExists) { throw DbException.get(ErrorCode.ROLE_NOT_FOUND_1, roleName); } } else { db.removeDatabaseObject(session, role); } return 0; }
@Override public int update() { session.commit(true); session.getUser().checkAdmin(); Database db = session.getDatabase(); if (table != null) { analyzeTable(session, table, sampleRows, true); } else { for (Table table : db.getAllTablesAndViews(false)) { analyzeTable(session, table, sampleRows, true); } } return 0; }
private static boolean cancelStatement(Session session, int targetSessionId) { session.getUser().checkAdmin(); Session[] sessions = session.getDatabase().getSessions(false); for (Session s : sessions) { if (s.getId() == targetSessionId) { Command c = s.getCurrentCommand(); if (c == null) { return false; } c.cancel(); return true; } } return false; }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); UserAggregate aggregate = db.findAggregate(name); if (aggregate == null) { if (!ifExists) { throw DbException.get(ErrorCode.AGGREGATE_NOT_FOUND_1, name); } } else { db.removeDatabaseObject(session, aggregate); } return 0; }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); UserDataType type = db.findUserDataType(typeName); if (type == null) { if (!ifExists) { throw DbException.get(ErrorCode.USER_DATA_TYPE_NOT_FOUND_1, typeName); } } else { db.removeDatabaseObject(session, type); } return 0; }
@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; }
@Override public int update() { session.commit(true); session.getUser().checkAdmin(); Database db = session.getDatabase(); if (db.findAggregate(name) != null || schema.findFunction(name) != null) { if (!ifNotExists) { throw DbException.get( ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, name); } } else { int id = getObjectId(); UserAggregate aggregate = new UserAggregate( db, id, name, javaClassMethod, force); db.addDatabaseObject(session, aggregate); } return 0; }
@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; }
@Override public int update() { if (!transactional) { session.commit(true); } session.getUser().checkAdmin(); Database db = session.getDatabase(); data.session = session; db.lockMeta(session); if (data.synonymForSchema.findTableOrView(session, data.synonymName) != null) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, data.synonymName); } if (data.synonymForSchema.findTableOrView(session, data.synonymFor) != null) { return createTableSynonym(db); } throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, data.synonymForSchema.getName() + "." + data.synonymFor); }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); if (db.findUser(roleName) != null) { throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, roleName); } if (db.findRole(roleName) != null) { if (ifNotExists) { return 0; } throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, roleName); } int id = getObjectId(); Role role = new Role(db, id, roleName, false); db.addDatabaseObject(session, role); return 0; }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); User user = db.findUser(userName); if (user == null) { if (!ifExists) { throw DbException.get(ErrorCode.USER_NOT_FOUND_1, userName); } } else { if (user == session.getUser()) { int adminUserCount = 0; for (User u : db.getAllUsers()) { if (u.isAdmin()) { adminUserCount++; } } if (adminUserCount == 1) { throw DbException.get(ErrorCode.CANNOT_DROP_CURRENT_USER); } } user.checkOwnsNoSchemas(); db.removeDatabaseObject(session, user); } return 0; }
@Override public int update() { session.commit(true); session.getUser().checkAdmin(); Database db = session.getDatabase(); if (getSchema().findConstant(constantName) != null) { if (ifNotExists) { return 0; } throw DbException.get(ErrorCode.CONSTANT_ALREADY_EXISTS_1, constantName); } int id = getObjectId(); Constant constant = new Constant(getSchema(), id, constantName); expression = expression.optimize(session); Value value = expression.getValue(session); constant.setValue(value); db.addSchemaObject(session, constant); return 0; }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); if (roleNames != null) { for (String name : roleNames) { Role grantedRole = db.findRole(name); if (grantedRole == null) { throw DbException.get(ErrorCode.ROLE_NOT_FOUND_1, name); } if (operationType == CommandInterface.GRANT) { grantRole(grantedRole); } else if (operationType == CommandInterface.REVOKE) { revokeRole(grantedRole); } else { DbException.throwInternalError("type=" + operationType); } } } else { if (operationType == CommandInterface.GRANT) { grantRight(); } else if (operationType == CommandInterface.REVOKE) { revokeRight(); } else { DbException.throwInternalError("type=" + operationType); } } return 0; }
@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; }
@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; }
@Override public int update() { session.getUser().checkAdmin(); session.commit(true); Database db = session.getDatabase(); if (db.findRole(userName) != null) { throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, userName); } if (db.findUser(userName) != null) { if (ifNotExists) { return 0; } throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, userName); } int id = getObjectId(); User user = new User(db, id, userName, false); user.setAdmin(admin); user.setComment(comment); if (hash != null && salt != null) { setSaltAndHash(user, session, salt, hash); } else if (password != null) { setPassword(user, session, password); } else { throw DbException.throwInternalError(); } db.addDatabaseObject(session, user); return 0; }