class AlterTableDropConstraint extends SchemaStatement {

    private String constraintName;
    private final boolean ifExists;

    public AlterTableDropConstraint(ServerSession session, Schema schema, boolean ifExists) {
        super(session, schema);
        this.ifExists = ifExists;
    }

    @Override
    public int getType() {
        return SQLStatement.ALTER_TABLE_DROP_CONSTRAINT;
    }

    public void setConstraintName(String string) {
        constraintName = string;
    }

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

        DbObjectLock lock = schema.tryExclusiveLock(DbObjectType.CONSTRAINT, session);
        if (lock == null)
            return -1;

        Constraint constraint = schema.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);
            schema.remove(session, constraint, lock);
        }
        return 0;
    
<methods>public void <init>(com.lealone.db.session.ServerSession, com.lealone.db.schema.Schema) <variables>protected final non-sealed com.lealone.db.schema.Schema schema