Search in sources :

Example 1 with TableFilterVisitor

use of org.h2.table.TableFilter.TableFilterVisitor in project h2database by h2database.

the class Parser method parseJoinTableFilter.

private void parseJoinTableFilter(TableFilter top, final Select command) {
    top = readJoin(top);
    command.addTableFilter(top, true);
    boolean isOuter = false;
    while (true) {
        TableFilter n = top.getNestedJoin();
        if (n != null) {
            n.visit(new TableFilterVisitor() {

                @Override
                public void accept(TableFilter f) {
                    command.addTableFilter(f, false);
                }
            });
        }
        TableFilter join = top.getJoin();
        if (join == null) {
            break;
        }
        isOuter = isOuter | join.isJoinOuter();
        if (isOuter) {
            command.addTableFilter(join, false);
        } else {
            // make flat so the optimizer can work better
            Expression on = join.getJoinCondition();
            if (on != null) {
                command.addCondition(on);
            }
            join.removeJoinCondition();
            top.removeJoin();
            command.addTableFilter(join, true);
        }
        top = join;
    }
}
Also used : TableFilter(org.h2.table.TableFilter) Expression(org.h2.expression.Expression) ValueExpression(org.h2.expression.ValueExpression) TableFilterVisitor(org.h2.table.TableFilter.TableFilterVisitor)

Aggregations

Expression (org.h2.expression.Expression)1 ValueExpression (org.h2.expression.ValueExpression)1 TableFilter (org.h2.table.TableFilter)1 TableFilterVisitor (org.h2.table.TableFilter.TableFilterVisitor)1