Search in sources :

Example 1 with ExpressionVisitor

use of com.wplatform.ddal.command.expression.ExpressionVisitor in project jdbc-shards by wplatform.

the class Select method isEverything.

@Override
public boolean isEverything(ExpressionVisitor visitor) {
    switch(visitor.getType()) {
        case ExpressionVisitor.DETERMINISTIC:
            {
                if (isForUpdate) {
                    return false;
                }
                for (int i = 0, size = filters.size(); i < size; i++) {
                    TableFilter f = filters.get(i);
                    if (!f.getTable().isDeterministic()) {
                        return false;
                    }
                }
                break;
            }
        case ExpressionVisitor.EVALUATABLE:
            {
                if (!session.getDatabase().getSettings().optimizeEvaluatableSubqueries) {
                    return false;
                }
                break;
            }
        case ExpressionVisitor.GET_DEPENDENCIES:
            {
                for (int i = 0, size = filters.size(); i < size; i++) {
                    TableFilter f = filters.get(i);
                    Table table = f.getTable();
                    visitor.addDependency(table);
                    table.addDependencies(visitor.getDependencies());
                }
                break;
            }
        default:
    }
    ExpressionVisitor v2 = visitor.incrementQueryLevel(1);
    boolean result = true;
    for (int i = 0, size = expressions.size(); i < size; i++) {
        Expression e = expressions.get(i);
        if (!e.isEverything(v2)) {
            result = false;
            break;
        }
    }
    if (result && condition != null && !condition.isEverything(v2)) {
        result = false;
    }
    if (result && having != null && !having.isEverything(v2)) {
        result = false;
    }
    return result;
}
Also used : Expression(com.wplatform.ddal.command.expression.Expression) ExpressionVisitor(com.wplatform.ddal.command.expression.ExpressionVisitor)

Example 2 with ExpressionVisitor

use of com.wplatform.ddal.command.expression.ExpressionVisitor in project jdbc-shards by wplatform.

the class Table method addDependencies.

/**
     * Add all objects that this table depends on to the hash set.
     *
     * @param dependencies the current set of dependencies
     */
public void addDependencies(HashSet<DbObject> dependencies) {
    if (dependencies.contains(this)) {
        // avoid endless recursion
        return;
    }
    if (sequences != null) {
        for (Sequence s : sequences) {
            dependencies.add(s);
        }
    }
    ExpressionVisitor visitor = ExpressionVisitor.getDependenciesVisitor(dependencies);
    for (Column col : columns) {
        col.isEverything(visitor);
    }
    dependencies.add(this);
}
Also used : Sequence(com.wplatform.ddal.dbobject.schema.Sequence) ExpressionVisitor(com.wplatform.ddal.command.expression.ExpressionVisitor)

Aggregations

ExpressionVisitor (com.wplatform.ddal.command.expression.ExpressionVisitor)2 Expression (com.wplatform.ddal.command.expression.Expression)1 Sequence (com.wplatform.ddal.dbobject.schema.Sequence)1