use of net.sf.jsqlparser.statement.truncate.Truncate 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;
}
use of net.sf.jsqlparser.statement.truncate.Truncate in project herddb by diennea.
the class TableSpaceMapper method getTableSpace.
public String getTableSpace(Statement statement) throws ScriptException {
String tableName = null;
if (statement instanceof Insert) {
Insert st = (Insert) statement;
tableName = st.getTable().getFullyQualifiedName();
} else if (statement instanceof Update) {
Update st = (Update) statement;
tableName = st.getTables().get(0).getFullyQualifiedName();
} else if (statement instanceof Delete) {
Delete st = (Delete) statement;
tableName = st.getTables().get(0).getFullyQualifiedName();
} else if (statement instanceof Truncate) {
Truncate st = (Truncate) statement;
tableName = st.getTable().getFullyQualifiedName();
} else if (statement instanceof Drop) {
Drop st = (Drop) statement;
tableName = st.getName().getFullyQualifiedName();
} else if (statement instanceof CreateTable) {
CreateTable st = (CreateTable) statement;
tableName = st.getTable().getFullyQualifiedName();
} else if (statement instanceof Alter) {
Alter st = (Alter) statement;
tableName = st.getTable().getFullyQualifiedName();
} else {
return null;
}
return mapTableNameToSchema(tableName);
}
use of net.sf.jsqlparser.statement.truncate.Truncate in project JSqlParser by JSQLParser.
the class TruncateTest method testTruncate.
@Test
public void testTruncate() throws Exception {
String statement = "TRUncATE TABLE myschema.mytab";
Truncate truncate = (Truncate) parserManager.parse(new StringReader(statement));
assertEquals("myschema", truncate.getTable().getSchemaName());
assertEquals("myschema.mytab", truncate.getTable().getFullyQualifiedName());
assertEquals(statement.toUpperCase(), truncate.toString().toUpperCase());
statement = "TRUncATE TABLE mytab";
String toStringStatement = "TRUncATE TABLE mytab";
truncate = (Truncate) parserManager.parse(new StringReader(statement));
assertEquals("mytab", truncate.getTable().getName());
assertEquals(toStringStatement.toUpperCase(), truncate.toString().toUpperCase());
}
Aggregations