Search in sources :

Example 1 with CompileContext

use of org.hsqldb_voltpatches.ParserDQL.CompileContext in project voltdb by VoltDB.

the class Expression method getCheckSelect.

/**
     * Returns a Select object that can be used for checking the contents
     * of an existing table against the given CHECK search condition.
     */
static QuerySpecification getCheckSelect(Session session, Table t, Expression e) {
    CompileContext compileContext = new CompileContext(session);
    QuerySpecification s = new QuerySpecification(compileContext);
    s.exprColumns = new Expression[1];
    s.exprColumns[0] = EXPR_TRUE;
    RangeVariable range = new RangeVariable(t, null, null, null, compileContext);
    s.rangeVariables = new RangeVariable[] { range };
    HsqlList unresolved = e.resolveColumnReferences(s.rangeVariables, null);
    ExpressionColumn.checkColumnsResolved(unresolved);
    e.resolveTypes(session, null);
    if (Type.SQL_BOOLEAN != e.getDataType()) {
        throw Error.error(ErrorCode.X_42568);
    }
    Expression condition = new ExpressionLogical(OpTypes.NOT, e);
    s.queryCondition = condition;
    s.resolveReferences(session);
    s.resolveTypes(session);
    return s;
}
Also used : CompileContext(org.hsqldb_voltpatches.ParserDQL.CompileContext) HsqlList(org.hsqldb_voltpatches.lib.HsqlList)

Aggregations

CompileContext (org.hsqldb_voltpatches.ParserDQL.CompileContext)1 HsqlList (org.hsqldb_voltpatches.lib.HsqlList)1