All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sqlancer.cockroachdb.ast.CockroachDBIndexReference Maven / Gradle / Ivy

Go to download

SQLancer finds logic bugs in Database Management Systems through automatic testing

There is a newer version: 2.0.0
Show newest version
package sqlancer.cockroachdb.ast;

import sqlancer.Randomly;
import sqlancer.common.schema.TableIndex;
import sqlancer.common.visitor.UnaryOperation;

public class CockroachDBIndexReference extends CockroachDBTableReference
        implements UnaryOperation {

    private final CockroachDBTableReference tableReference;
    private final TableIndex index;

    public CockroachDBIndexReference(CockroachDBTableReference tableReference, TableIndex index) {
        super(tableReference.getTable());
        this.tableReference = tableReference;
        this.index = index;
    }

    @Override
    public CockroachDBExpression getExpression() {
        return tableReference;
    }

    @Override
    public String getOperatorRepresentation() {
        if (Randomly.getBoolean()) {
            return String.format("@{FORCE_INDEX=%s}", index.getIndexName());
        } else {
            return String.format("@{FORCE_INDEX=%s,%s}", index.getIndexName(), Randomly.fromOptions("ASC", "DESC"));
        }
    }

    @Override
    public OperatorKind getOperatorKind() {
        return OperatorKind.POSTFIX;
    }

    @Override
    public boolean omitBracketsWhenPrinting() {
        return true;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy