private String readIdentifierWithSchema() { return readIdentifierWithSchema(session.getCurrentSchemaName()); }
private Table readTableOrView() { return readTableOrView(readIdentifierWithSchema(null)); }
private AlterSchemaRename parseAlterSchema() { String schemaName = readIdentifierWithSchema(); Schema old = getSchema(); AlterSchemaRename command = new AlterSchemaRename(session); command.setOldSchema(getSchema(schemaName)); read("RENAME"); read("TO"); String newName = readIdentifierWithSchema(old.getName()); checkSchema(old); command.setNewName(newName); return command; }
private AlterIndexRename parseAlterIndex() { String indexName = readIdentifierWithSchema(); Schema old = getSchema(); AlterIndexRename command = new AlterIndexRename(session); command.setOldIndex(getSchema().getIndex(indexName)); read("RENAME"); read("TO"); String newName = readIdentifierWithSchema(old.getName()); checkSchema(old); command.setNewName(newName); return command; }
private Sequence readSequence() { // same algorithm as readTableOrView String sequenceName = readIdentifierWithSchema(null); if (schemaName != null) { return getSchema().getSequence(sequenceName); } Sequence sequence = findSequence(session.getCurrentSchemaName(), sequenceName); if (sequence != null) { return sequence; } throw DbException.get(ErrorCode.SEQUENCE_NOT_FOUND_1, sequenceName); }
private AlterView parseAlterView() { AlterView command = new AlterView(session); String viewName = readIdentifierWithSchema(); Table tableView = getSchema().findTableOrView(session, viewName); if (!(tableView instanceof TableView)) { throw DbException.get(ErrorCode.VIEW_NOT_FOUND_1, viewName); } TableView view = (TableView) tableView; command.setView(view); read("RECOMPILE"); return command; }
String tableName = readIdentifierWithSchema(); String schemaName = getSchema().getName(); paramValues.add(ValueString.get(tableName)); String tableName = readIdentifierWithSchema(); buff.append("OBJECT_NAME TABLE_NAME, DATA_NODE, " + "NODE_NAME, NODE_TYPE, "
private CreateConstant parseCreateConstant() { boolean ifNotExists = readIfNotExists(); String constantName = readIdentifierWithSchema(); Schema schema = getSchema(); if (isKeyword(constantName)) { throw DbException.get(ErrorCode.CONSTANT_ALREADY_EXISTS_1, constantName); } read("VALUE"); Expression expr = readExpression(); CreateConstant command = new CreateConstant(session, schema); command.setConstantName(constantName); command.setExpression(expr); command.setIfNotExists(ifNotExists); return command; }
private CreateAggregate parseCreateAggregate(boolean force) { boolean ifNotExists = readIfNotExists(); CreateAggregate command = new CreateAggregate(session); command.setForce(force); String name = readIdentifierWithSchema(); if (isKeyword(name) || Function.getFunction(database, name) != null || getAggregateType(name) >= 0) { throw DbException.get(ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, name); } command.setName(name); command.setSchema(getSchema()); command.setIfNotExists(ifNotExists); read("FOR"); command.setJavaClassMethod(readUniqueIdentifier()); return command; }
private void parseReferences(AlterTableAddConstraint command, Schema schema, String tableName) { if (readIf("(")) { command.setRefTableName(schema, tableName); command.setRefIndexColumns(parseIndexColumnList()); } else { String refTableName = readIdentifierWithSchema(schema.getName()); command.setRefTableName(getSchema(), refTableName); if (readIf("(")) { command.setRefIndexColumns(parseIndexColumnList()); } } if (readIf("INDEX")) { String indexName = readIdentifierWithSchema(); command.setRefIndex(getSchema().findIndex(session, indexName)); } while (readIf("ON")) { if (readIf("DELETE")) { command.setDeleteAction(parseAction()); } else { read("UPDATE"); command.setUpdateAction(parseAction()); } } if (readIf("NOT")) { read("DEFERRABLE"); } else { readIf("DEFERRABLE"); } }
private CreateView parseCreateView(boolean force, boolean orReplace) { boolean ifNotExists = readIfNotExists(); String viewName = readIdentifierWithSchema(); CreateView command = new CreateView(session, getSchema()); command.setViewName(viewName);
private Prepared parseDrop() { if (readIf("TABLE")) { boolean ifExists = readIfExists(false); String tableName = readIdentifierWithSchema(); DropTable command = new DropTable(session, getSchema()); command.setTableName(tableName); while (readIf(",")) { tableName = readIdentifierWithSchema(); DropTable next = new DropTable(session, getSchema()); next.setTableName(tableName); } else if (readIf("INDEX")) { boolean ifExists = readIfExists(false); String indexName = readIdentifierWithSchema(); DropIndex command = new DropIndex(session, getSchema()); command.setIndexName(indexName); String tableName = readIdentifierWithSchema(); command.setTableName(tableName); } else if (readIf("SEQUENCE")) { boolean ifExists = readIfExists(false); String sequenceName = readIdentifierWithSchema(); DropSequence command = new DropSequence(session, getSchema()); command.setSequenceName(sequenceName); } else if (readIf("CONSTANT")) { boolean ifExists = readIfExists(false); String constantName = readIdentifierWithSchema(); DropConstant command = new DropConstant(session, getSchema());
private Query parseWith() { readIf("RECURSIVE"); String tempViewName = readIdentifierWithSchema(); Schema schema = getSchema(); Table recursiveTable;
if (readIf("CONSTRAINT")) { ifNotExists = readIfNotExists(); constraintName = readIdentifierWithSchema(schema.getName()); checkSchema(schema); comment = readCommentIf(); command.setIndexColumns(parseIndexColumnList()); if (readIf("INDEX")) { String indexName = readIdentifierWithSchema(); command.setIndex(getSchema().findIndex(session, indexName)); String indexName = readIdentifierWithSchema(); command.setIndex(getSchema().findIndex(session, indexName)); command.setIndexColumns(parseIndexColumnList()); if (readIf("INDEX")) { String indexName = readIdentifierWithSchema(); command.setIndex(schema.findIndex(session, indexName));
table = parseValuesTable().getTable(); } else { String tableName = readIdentifierWithSchema(null); Schema schema = getSchema(); boolean foundLeftBracket = readIf("("); readIdentifierWithSchema(null); read(")"); foundLeftBracket = false;
if (!isToken("ON")) { ifNotExists = readIfNotExists(); indexName = readIdentifierWithSchema(null); oldSchema = getSchema(); if (!isToken("ON")) { ifNotExists = readIfNotExists(); indexName = readIdentifierWithSchema(null); oldSchema = getSchema(); String tableName = readIdentifierWithSchema(); checkSchema(oldSchema); CreateIndex command = new CreateIndex(session, getSchema());
private AlterSequence parseAlterSequence() { String sequenceName = readIdentifierWithSchema(); Sequence sequence = getSchema().getSequence(sequenceName); AlterSequence command = new AlterSequence(session, sequence.getSchema());
private CreateSequence parseCreateSequence() { boolean ifNotExists = readIfNotExists(); String sequenceName = readIdentifierWithSchema(); CreateSequence command = new CreateSequence(session, getSchema()); command.setIfNotExists(ifNotExists);
if (readIf("OF")) { do { readIdentifierWithSchema(); } while (readIf(",")); } else if (readIf("NOWAIT")) {
private CreateTable parseCreateTable(boolean temp, boolean globalTemp) { boolean ifNotExists = readIfNotExists(); String tableName = readIdentifierWithSchema(); if (temp && globalTemp && equalsToken("SESSION", schemaName)) {