Search in sources :

Example 1 with CreateIndex

use of net.sf.jsqlparser.statement.create.index.CreateIndex 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 CreateIndex

use of net.sf.jsqlparser.statement.create.index.CreateIndex in project herddb by diennea.

the class JdbcQueryRewriter method visit.

@Override
public void visit(CreateIndex createIndex) {
    visit(createIndex.getTable());
    Index index = createIndex.getIndex();
    visit(index);
}
Also used : CreateIndex(net.sf.jsqlparser.statement.create.index.CreateIndex) Index(net.sf.jsqlparser.statement.create.table.Index)

Example 3 with CreateIndex

use of net.sf.jsqlparser.statement.create.index.CreateIndex in project JSqlParser by JSQLParser.

the class CreateIndexTest method testCreateIndex4.

@Test
public void testCreateIndex4() throws JSQLParserException {
    String statement = "CREATE mytype INDEX myindex ON mytab (mycol ASC, mycol2 (75), mycol3)";
    CreateIndex createIndex = (CreateIndex) parserManager.parse(new StringReader(statement));
    assertEquals(3, createIndex.getIndex().getColumnsNames().size());
    assertEquals("myindex", createIndex.getIndex().getName());
    assertEquals("mytype", createIndex.getIndex().getType());
    assertEquals("mytab", createIndex.getTable().getFullyQualifiedName());
    assertEquals("mycol3", createIndex.getIndex().getColumnsNames().get(2));
}
Also used : CreateIndex(net.sf.jsqlparser.statement.create.index.CreateIndex) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 4 with CreateIndex

use of net.sf.jsqlparser.statement.create.index.CreateIndex in project JSqlParser by JSQLParser.

the class CreateIndexTest method testCreateIndex3.

@Test
public void testCreateIndex3() throws JSQLParserException {
    String statement = "CREATE mytype INDEX myindex ON mytab (mycol ASC, mycol2, mycol3)";
    CreateIndex createIndex = (CreateIndex) parserManager.parse(new StringReader(statement));
    assertEquals(3, createIndex.getIndex().getColumnsNames().size());
    assertEquals("myindex", createIndex.getIndex().getName());
    assertEquals("mytype", createIndex.getIndex().getType());
    assertEquals("mytab", createIndex.getTable().getFullyQualifiedName());
    assertEquals("mycol3", createIndex.getIndex().getColumnsNames().get(2));
}
Also used : CreateIndex(net.sf.jsqlparser.statement.create.index.CreateIndex) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 5 with CreateIndex

use of net.sf.jsqlparser.statement.create.index.CreateIndex in project JSqlParser by JSQLParser.

the class CreateIndexTest method testCreateIndex.

@Test
public void testCreateIndex() throws JSQLParserException {
    String statement = "CREATE INDEX myindex ON mytab (mycol, mycol2)";
    CreateIndex createIndex = (CreateIndex) parserManager.parse(new StringReader(statement));
    assertEquals(2, createIndex.getIndex().getColumnsNames().size());
    assertEquals("myindex", createIndex.getIndex().getName());
    assertNull(createIndex.getIndex().getType());
    assertEquals("mytab", createIndex.getTable().getFullyQualifiedName());
    assertEquals("mycol", createIndex.getIndex().getColumnsNames().get(0));
    assertEquals(statement, "" + createIndex);
}
Also used : CreateIndex(net.sf.jsqlparser.statement.create.index.CreateIndex) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

CreateIndex (net.sf.jsqlparser.statement.create.index.CreateIndex)11 StringReader (java.io.StringReader)5 Test (org.junit.Test)5 Alter (net.sf.jsqlparser.statement.alter.Alter)3 CreateTable (net.sf.jsqlparser.statement.create.table.CreateTable)3 Index (net.sf.jsqlparser.statement.create.table.Index)3 Delete (net.sf.jsqlparser.statement.delete.Delete)3 Drop (net.sf.jsqlparser.statement.drop.Drop)3 Insert (net.sf.jsqlparser.statement.insert.Insert)3 Update (net.sf.jsqlparser.statement.update.Update)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Table (net.sf.jsqlparser.schema.Table)2 CreateView (net.sf.jsqlparser.statement.create.view.CreateView)2 DBException (org.jkiss.dbeaver.DBException)2 AbstractTableManager (herddb.core.AbstractTableManager)1 Column (herddb.model.Column)1 ExecutionPlan (herddb.model.ExecutionPlan)1 StatementExecutionException (herddb.model.StatementExecutionException)1 TableDoesNotExistException (herddb.model.TableDoesNotExistException)1