class AlterUser extends UserStatement {

    private int type;
    private User user;
    private String newName;
    private boolean admin;

    public AlterUser(ServerSession session) {
        super(session);
    }

    @Override
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setNewName(String newName) {
        this.newName = newName;
    }

    public void setAdmin(boolean admin) {
        this.admin = admin;
    }

    @Override
    public int update() {<FILL_FUNCTION_BODY>}
}

        Database db = session.getDatabase();
        DbObjectLock lock = db.tryExclusiveAuthLock(session);
        if (lock == null)
            return -1;

        switch (type) {
        case SQLStatement.ALTER_USER_SET_PASSWORD:
            if (user != session.getUser()) {
                session.getUser().checkAdmin();
            }
            if (hash != null && salt != null) {
                CreateUser.setSaltAndHash(user, session, salt, hash);
            } else {
                CreateUser.setPassword(user, session, password);
            }
            db.updateMeta(session, user);
            break;
        case SQLStatement.ALTER_USER_RENAME:
            session.getUser().checkAdmin();
            if (db.findUser(session, newName) != null || newName.equals(user.getName())) {
                throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, newName);
            }
            db.renameDatabaseObject(session, user, newName, lock);
            break;
        case SQLStatement.ALTER_USER_ADMIN:
            session.getUser().checkAdmin();
            if (!admin) {
                user.checkOwnsNoSchemas(session);
            }
            user.setAdmin(admin);
            db.updateMeta(session, user);
            break;
        default:
            DbException.throwInternalError("type=" + type);
        }
        return 0;
    
<methods>public void setHash(com.lealone.sql.expression.Expression) ,public void setHashMongo(com.lealone.sql.expression.Expression) ,public void setHashMySQL(com.lealone.sql.expression.Expression) ,public void setHashPostgreSQL(com.lealone.sql.expression.Expression) ,public void setPassword(com.lealone.sql.expression.Expression) ,public void setSalt(com.lealone.sql.expression.Expression) ,public void setSaltMongo(com.lealone.sql.expression.Expression) ,public void setSaltMySQL(com.lealone.sql.expression.Expression) ,public void setSaltPostgreSQL(com.lealone.sql.expression.Expression) <variables>protected com.lealone.sql.expression.Expression hash,protected com.lealone.sql.expression.Expression hashMongo,protected com.lealone.sql.expression.Expression hashMySQL,protected com.lealone.sql.expression.Expression hashPostgreSQL,protected com.lealone.sql.expression.Expression password,protected com.lealone.sql.expression.Expression salt,protected com.lealone.sql.expression.Expression saltMongo,protected com.lealone.sql.expression.Expression saltMySQL,protected com.lealone.sql.expression.Expression saltPostgreSQL