Search in sources :

Example 1 with AdHocPlanningException

use of org.voltdb.sysprocs.AdHocNTBase.AdHocPlanningException in project voltdb by VoltDB.

the class CatalogSpecificPlanner method plan.

public AdHocPlannedStmtBatch plan(String sql, Object[] userParams, boolean singlePartition) throws AdHocPlanningException {
    List<String> sqlStatements = new ArrayList<>();
    AdHocSQLMix mix = AdHocNTBase.processAdHocSQLStmtTypes(sql, sqlStatements);
    switch(mix) {
        case EMPTY:
            throw new AdHocPlanningException("No valid SQL found.");
        case ALL_DDL:
        case MIXED:
            throw new AdHocPlanningException("DDL not supported in stored procedures.");
        default:
            break;
    }
    if (sqlStatements.size() != 1) {
        throw new AdHocPlanningException("Only one statement is allowed in stored procedure, but received " + sqlStatements.size());
    }
    sql = sqlStatements.get(0);
    // any object will signify SP
    Object partitionKey = singlePartition ? "1" : null;
    List<AdHocPlannedStatement> stmts = new ArrayList<>();
    AdHocPlannedStatement result = null;
    result = AdHocNTBase.compileAdHocSQL(m_catalogContext, sql, false, partitionKey, ExplainMode.NONE, false, userParams);
    stmts.add(result);
    return new AdHocPlannedStmtBatch(userParams, stmts, -1, null, null, userParams);
}
Also used : AdHocSQLMix(org.voltdb.sysprocs.AdHocNTBase.AdHocSQLMix) AdHocPlannedStatement(org.voltdb.compiler.AdHocPlannedStatement) AdHocPlanningException(org.voltdb.sysprocs.AdHocNTBase.AdHocPlanningException) ArrayList(java.util.ArrayList) AdHocPlannedStmtBatch(org.voltdb.compiler.AdHocPlannedStmtBatch)

Aggregations

ArrayList (java.util.ArrayList)1 AdHocPlannedStatement (org.voltdb.compiler.AdHocPlannedStatement)1 AdHocPlannedStmtBatch (org.voltdb.compiler.AdHocPlannedStmtBatch)1 AdHocPlanningException (org.voltdb.sysprocs.AdHocNTBase.AdHocPlanningException)1 AdHocSQLMix (org.voltdb.sysprocs.AdHocNTBase.AdHocSQLMix)1