Search in sources :

Example 1 with Execute

use of net.sf.jsqlparser.statement.execute.Execute in project herddb by diennea.

the class SQLPlanner method plan.

@Override
public ExecutionPlan plan(String defaultTableSpace, net.sf.jsqlparser.statement.Statement stmt, boolean scan, boolean returnValues, int maxRows) {
    verifyJdbcParametersIndexes(stmt);
    ExecutionPlan result;
    if (stmt instanceof CreateTable) {
        result = ExecutionPlan.simple(buildCreateTableStatement(defaultTableSpace, (CreateTable) stmt));
    } else if (stmt instanceof CreateIndex) {
        result = ExecutionPlan.simple(buildCreateIndexStatement(defaultTableSpace, (CreateIndex) stmt));
    } else if (stmt instanceof Insert) {
        result = buildInsertStatement(defaultTableSpace, (Insert) stmt, returnValues);
    } else if (stmt instanceof Delete) {
        result = buildDeleteStatement(defaultTableSpace, (Delete) stmt, returnValues);
    } else if (stmt instanceof Update) {
        result = buildUpdateStatement(defaultTableSpace, (Update) stmt, returnValues);
    } else if (stmt instanceof Select) {
        result = buildSelectStatement(defaultTableSpace, (Select) stmt, scan, maxRows);
    } else if (stmt instanceof Execute) {
        result = ExecutionPlan.simple(buildExecuteStatement(defaultTableSpace, (Execute) stmt));
    } else if (stmt instanceof Alter) {
        result = ExecutionPlan.simple(buildAlterStatement(defaultTableSpace, (Alter) stmt));
    } else if (stmt instanceof Drop) {
        result = ExecutionPlan.simple(buildDropStatement(defaultTableSpace, (Drop) stmt));
    } else if (stmt instanceof Truncate) {
        result = ExecutionPlan.simple(buildTruncateStatement(defaultTableSpace, (Truncate) stmt));
    } else {
        return null;
    }
    return result;
}
Also used : Delete(net.sf.jsqlparser.statement.delete.Delete) Alter(net.sf.jsqlparser.statement.alter.Alter) ExecutionPlan(herddb.model.ExecutionPlan) CreateIndex(net.sf.jsqlparser.statement.create.index.CreateIndex) Execute(net.sf.jsqlparser.statement.execute.Execute) CreateTable(net.sf.jsqlparser.statement.create.table.CreateTable) PlainSelect(net.sf.jsqlparser.statement.select.PlainSelect) Select(net.sf.jsqlparser.statement.select.Select) Truncate(net.sf.jsqlparser.statement.truncate.Truncate) Insert(net.sf.jsqlparser.statement.insert.Insert) Update(net.sf.jsqlparser.statement.update.Update) Drop(net.sf.jsqlparser.statement.drop.Drop)

Example 2 with Execute

use of net.sf.jsqlparser.statement.execute.Execute in project JSqlParser by JSQLParser.

the class ExecuteDeParserTest method shouldDeParseExecute.

@Test
public void shouldDeParseExecute() {
    Execute execute = new Execute();
    String name = "name";
    ExpressionList exprList = new ExpressionList();
    List<Expression> expressions = new ArrayList<Expression>();
    Expression expression1 = mock(Expression.class);
    Expression expression2 = mock(Expression.class);
    execute.setName(name);
    execute.setExprList(exprList);
    exprList.setExpressions(expressions);
    expressions.add(expression1);
    expressions.add(expression2);
    executeDeParser.deParse(execute);
    String actual = buffer.toString();
    assertTrue(actual.matches("EXECUTE " + name + " .*?, .*"));
}
Also used : Execute(net.sf.jsqlparser.statement.execute.Execute) Expression(net.sf.jsqlparser.expression.Expression) ArrayList(java.util.ArrayList) ExpressionList(net.sf.jsqlparser.expression.operators.relational.ExpressionList) Test(org.junit.Test)

Example 3 with Execute

use of net.sf.jsqlparser.statement.execute.Execute in project JSqlParser by JSQLParser.

the class StatementDeParserTest method shouldUseProvidedDeParserWhenDeParsingExecute.

@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeParserWhenDeParsingExecute() {
    Execute execute = new Execute();
    ExpressionList exprList = new ExpressionList();
    List<Expression> expressions = new ArrayList<Expression>();
    Expression expression1 = mock(Expression.class);
    Expression expression2 = mock(Expression.class);
    execute.setExprList(exprList);
    exprList.setExpressions(expressions);
    expressions.add(expression1);
    expressions.add(expression2);
    statementDeParser.visit(execute);
    then(expression1).should().accept(expressionDeParser);
    then(expression2).should().accept(expressionDeParser);
}
Also used : Execute(net.sf.jsqlparser.statement.execute.Execute) Expression(net.sf.jsqlparser.expression.Expression) ArrayList(java.util.ArrayList) ExpressionList(net.sf.jsqlparser.expression.operators.relational.ExpressionList) Test(org.junit.Test)

Example 4 with Execute

use of net.sf.jsqlparser.statement.execute.Execute in project JSqlParser by JSQLParser.

the class ExecuteDeParserTest method shouldUseProvidedExpressionVisitorWhenDeParsingExecute.

@Test
public void shouldUseProvidedExpressionVisitorWhenDeParsingExecute() {
    Execute execute = new Execute();
    String name = "name";
    ExpressionList exprList = new ExpressionList();
    List<Expression> expressions = new ArrayList<Expression>();
    Expression expression1 = mock(Expression.class);
    Expression expression2 = mock(Expression.class);
    execute.setName(name);
    execute.setExprList(exprList);
    exprList.setExpressions(expressions);
    expressions.add(expression1);
    expressions.add(expression2);
    executeDeParser.deParse(execute);
    then(expression1).should().accept(expressionVisitor);
    then(expression2).should().accept(expressionVisitor);
}
Also used : Execute(net.sf.jsqlparser.statement.execute.Execute) Expression(net.sf.jsqlparser.expression.Expression) ArrayList(java.util.ArrayList) ExpressionList(net.sf.jsqlparser.expression.operators.relational.ExpressionList) Test(org.junit.Test)

Aggregations

Execute (net.sf.jsqlparser.statement.execute.Execute)4 ArrayList (java.util.ArrayList)3 Expression (net.sf.jsqlparser.expression.Expression)3 ExpressionList (net.sf.jsqlparser.expression.operators.relational.ExpressionList)3 Test (org.junit.Test)3 ExecutionPlan (herddb.model.ExecutionPlan)1 Alter (net.sf.jsqlparser.statement.alter.Alter)1 CreateIndex (net.sf.jsqlparser.statement.create.index.CreateIndex)1 CreateTable (net.sf.jsqlparser.statement.create.table.CreateTable)1 Delete (net.sf.jsqlparser.statement.delete.Delete)1 Drop (net.sf.jsqlparser.statement.drop.Drop)1 Insert (net.sf.jsqlparser.statement.insert.Insert)1 PlainSelect (net.sf.jsqlparser.statement.select.PlainSelect)1 Select (net.sf.jsqlparser.statement.select.Select)1 Truncate (net.sf.jsqlparser.statement.truncate.Truncate)1 Update (net.sf.jsqlparser.statement.update.Update)1