Search in sources :

Example 1 with VoltCompilerException

use of org.voltdb.compiler.VoltCompiler.VoltCompilerException in project voltdb by VoltDB.

the class DropRole method processStatement.

@Override
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
    // matches if it is DROP ROLE
    // group 1 is role name
    Matcher statementMatcher = SQLParser.matchDropRole(ddlStatement.statement);
    if (!statementMatcher.matches()) {
        return false;
    }
    String roleName = statementMatcher.group(1).toUpperCase();
    boolean ifExists = (statementMatcher.group(2) != null);
    CatalogMap<Group> groupMap = db.getGroups();
    if (groupMap.get(roleName) == null) {
        if (!ifExists) {
            throw m_compiler.new VoltCompilerException(String.format("Role name \"%s\" in DROP ROLE statement does not exist.", roleName));
        } else {
            return true;
        }
    } else {
        // dropped.
        if (roleName.equals("ADMINISTRATOR") || roleName.equals("USER")) {
            throw m_compiler.new VoltCompilerException(String.format("You may not drop the built-in role \"%s\".", roleName));
        }
        // The constraint that there be no users with this role gets
        // checked by the deployment validation.  *HOWEVER*, right now
        // this ends up giving a confusing error message.
        groupMap.delete(roleName);
    }
    return true;
}
Also used : Group(org.voltdb.catalog.Group) Matcher(java.util.regex.Matcher) VoltCompilerException(org.voltdb.compiler.VoltCompiler.VoltCompilerException)

Example 2 with VoltCompilerException

use of org.voltdb.compiler.VoltCompiler.VoltCompilerException in project voltdb by VoltDB.

the class ImportClass method processStatement.

@Override
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
    // match IMPORT CLASS statements
    Matcher statementMatcher = SQLParser.matchImportClass(ddlStatement.statement);
    if (!statementMatcher.matches()) {
        return false;
    }
    if (whichProcs == DdlProceduresToLoad.ALL_DDL_PROCEDURES) {
        // Command-line compilation will never have an InMemoryJarfile.
        if (!(m_classLoader instanceof InMemoryJarfile.JarLoader)) {
            // Only process the statement if this is not for the StatementPlanner
            String classNameStr = statementMatcher.group(1);
            // check that the match pattern is a valid match pattern
            checkIdentifierWithWildcard(classNameStr, ddlStatement.statement);
            ClassNameMatchStatus matchStatus = m_classMatcher.addPattern(classNameStr);
            if (matchStatus == ClassNameMatchStatus.NO_EXACT_MATCH) {
                throw m_compiler.new VoltCompilerException(String.format("IMPORT CLASS not found: '%s'", // remove trailing semicolon
                classNameStr));
            } else if (matchStatus == ClassNameMatchStatus.NO_WILDCARD_MATCH) {
                m_compiler.addWarn(String.format("IMPORT CLASS no match for wildcarded class: '%s'", classNameStr), ddlStatement.lineNo);
            }
        } else {
            m_compiler.addInfo("Internal cluster recompilation ignoring IMPORT CLASS line: " + ddlStatement.statement);
        }
        // Need to track the IMPORT CLASS lines even on internal compiles so that
        // we don't lose them from the DDL source.  When the @UAC path goes away,
        // we could change this.
        m_tracker.addImportLine(ddlStatement.statement);
    }
    return true;
}
Also used : Matcher(java.util.regex.Matcher) VoltCompilerException(org.voltdb.compiler.VoltCompiler.VoltCompilerException) ClassNameMatchStatus(org.voltdb.compiler.ClassMatcher.ClassNameMatchStatus)

Example 3 with VoltCompilerException

use of org.voltdb.compiler.VoltCompiler.VoltCompilerException in project voltdb by VoltDB.

the class PartitionStatement method processPartitionProcedure.

private boolean processPartitionProcedure(DDLStatement ddlStatement, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
    if (whichProcs != DdlProceduresToLoad.ALL_DDL_PROCEDURES) {
        return true;
    }
    // matches if it is
    //   PARTITION PROCEDURE <procedure>
    //      ON  TABLE <table> COLUMN <column> [PARAMETER <parameter-index-no>]
    Matcher statementMatcher = SQLParser.matchPartitionProcedure(ddlStatement.statement);
    if (!statementMatcher.matches()) {
        throw m_compiler.new VoltCompilerException(String.format("Invalid PARTITION statement: \"%s\", " + "expected syntax: PARTITION PROCEDURE <procedure> ON " + "TABLE <table> COLUMN <column> [PARAMETER <parameter-index-no>]", // remove trailing semicolon
        ddlStatement.statement.substring(0, ddlStatement.statement.length() - 1)));
    }
    // check the table portion of the partition info
    String tableName = checkIdentifierStart(statementMatcher.group(2), ddlStatement.statement);
    // check the column portion of the partition info
    String columnName = checkIdentifierStart(statementMatcher.group(3), ddlStatement.statement);
    // if not specified default parameter index to 0
    String parameterNo = statementMatcher.group(4);
    if (parameterNo == null) {
        parameterNo = "0";
    }
    String partitionInfo = String.format("%s.%s: %s", tableName, columnName, parameterNo);
    // procedureName -> group(1), partitionInfo -> group(2)
    m_tracker.addProcedurePartitionInfoTo(checkIdentifierStart(statementMatcher.group(1), ddlStatement.statement), partitionInfo);
    // this command is now deprecated as of VoltDB 7.0
    m_compiler.addWarn("The standalone \"PARTITION PROCEDURE ...\" statement is deprecated. " + "Please use the combined statement \"CREATE PROCEDURE PARTITION ON ...\" " + "instead. See the documentation of \"CREATE PROCEDURE\" for more information.", ddlStatement.lineNo);
    return true;
}
Also used : Matcher(java.util.regex.Matcher) VoltCompilerException(org.voltdb.compiler.VoltCompiler.VoltCompilerException)

Example 4 with VoltCompilerException

use of org.voltdb.compiler.VoltCompiler.VoltCompilerException in project voltdb by VoltDB.

the class SetGlobalParam method processStatement.

@Override
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
    Matcher statementMatcher = SQLParser.matchSetGlobalParam(ddlStatement.statement);
    if (!statementMatcher.matches()) {
        return false;
    }
    String name = statementMatcher.group(1).toUpperCase();
    switch(name) {
        case DatabaseConfiguration.DR_MODE_NAME:
            m_compiler.addWarn("Setting DR mode in the DDL is deprecated. Please use the role attribute of the <dr> tag in the deployment file.");
            break;
        default:
            throw m_compiler.new VoltCompilerException(String.format("Unknown global parameter: %s. Candidate parameters are %s", name, DatabaseConfiguration.allNames));
    }
    return true;
}
Also used : Matcher(java.util.regex.Matcher) VoltCompilerException(org.voltdb.compiler.VoltCompiler.VoltCompilerException)

Example 5 with VoltCompilerException

use of org.voltdb.compiler.VoltCompiler.VoltCompilerException in project voltdb by VoltDB.

the class ReplicateTable method processStatement.

@Override
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
    // matches if it is REPLICATE TABLE <table-name>
    Matcher statementMatcher = SQLParser.matchReplicateTable(ddlStatement.statement);
    if (!statementMatcher.matches()) {
        return false;
    }
    // group(1) -> table
    String tableName = checkIdentifierStart(statementMatcher.group(1), ddlStatement.statement);
    VoltXMLElement tableXML = m_schema.findChild("table", tableName.toUpperCase());
    if (tableXML != null) {
        tableXML.attributes.remove("partitioncolumn");
        // mark the table as dirty for the purposes of caching sql statements
        m_compiler.markTableAsDirty(tableName);
    } else {
        throw m_compiler.new VoltCompilerException(String.format("Invalid REPLICATE statement: table %s does not exist", tableName));
    }
    return true;
}
Also used : Matcher(java.util.regex.Matcher) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement) VoltCompilerException(org.voltdb.compiler.VoltCompiler.VoltCompilerException)

Aggregations

VoltCompilerException (org.voltdb.compiler.VoltCompiler.VoltCompilerException)38 Matcher (java.util.regex.Matcher)15 Constraint (org.voltdb.catalog.Constraint)11 VoltXMLElement (org.hsqldb_voltpatches.VoltXMLElement)10 Column (org.voltdb.catalog.Column)7 AbstractExpression (org.voltdb.expressions.AbstractExpression)7 VoltType (org.voltdb.VoltType)6 Index (org.voltdb.catalog.Index)5 IOException (java.io.IOException)4 HSQLParseException (org.hsqldb_voltpatches.HSQLInterface.HSQLParseException)4 JSONException (org.json_voltpatches.JSONException)4 VoltTypeException (org.voltdb.VoltTypeException)4 Group (org.voltdb.catalog.Group)4 ProcParameter (org.voltdb.catalog.ProcParameter)4 Statement (org.voltdb.catalog.Statement)4 Table (org.voltdb.catalog.Table)4 Method (java.lang.reflect.Method)3 ArrayList (java.util.ArrayList)3 ColumnRef (org.voltdb.catalog.ColumnRef)3 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)3