private CreateSchema parseCreateSchema() { CreateSchema command = new CreateSchema(session); command.setIfNotExists(readIfNotExists()); command.setSchemaName(readUniqueIdentifier()); if (readIf("AUTHORIZATION")) { command.setAuthorization(readUniqueIdentifier()); } else { command.setAuthorization(session.getUser().getName()); } return command; }
private boolean readIfExists(boolean ifExists) { if (readIf("IF")) { read("EXISTS"); ifExists = true; } return ifExists; }
private void parseSelectSimpleFromPart(Select command) { do { TableFilter filter = readTableFilter(false); parseJoinTableFilter(filter, command); } while (readIf(",")); }
private Prepared parseDeallocate() { readIf("PLAN"); readAliasIdentifier(); return new NoOperation(session); }
private boolean readIfNotExists() { if (readIf("IF")) { read("NOT"); read("EXISTS"); return true; } return false; }
private TransactionCommand parseCommit() { TransactionCommand command; if (readIf("TRANSACTION")) { command = new TransactionCommand(session, CommandInterface.COMMIT_TRANSACTION); command.setTransactionName(readUniqueIdentifier()); return command; } command = new TransactionCommand(session, CommandInterface.COMMIT); readIf("WORK"); return command; }
private Query parseSelectSub() { if (readIf("(")) { Query command = parseSelectUnion(); read(")"); return command; } Select select = parseSelectSimple(); return select; }
private boolean isSelect() { int start = lastParseIndex; while (readIf("(")) { // need to read ahead, it could be a nested union: // ((select 1) union (select 1)) } boolean select = isToken("SELECT") || isToken("FROM"); parseIndex = start; read(); return select; }
private Function readFunctionWithoutParameters(String name) { if (readIf("(")) { read(")"); } Function function = Function.getFunction(database, name); function.doneWithParameters(); return function; }
private Prepared parseReleaseSavepoint() { TransactionCommand command = new TransactionCommand(session, CommandInterface.RELEASE_SAVEPOINT); readIf("SAVEPOINT"); command.setSavepointName(readUniqueIdentifier()); return command; }
private Expression readAnd() { Expression r = readCondition(); while (readIf("AND")) { r = new ConditionAndOr(ConditionAndOr.AND, r, readCondition()); } return r; }
private Expression readExpression() { Expression r = readAnd(); while (readIf("OR")) { r = new ConditionAndOr(ConditionAndOr.OR, r, readAnd()); } return r; }
private String readFromAlias(String alias) { if (readIf("AS")) { alias = readAliasIdentifier(); } else if (currentTokenType == IDENTIFIER) { // left and right are not keywords (because they are functions as // well) if (!isToken("LEFT") && !isToken("RIGHT") && !isToken("FULL")) { alias = readAliasIdentifier(); } } return alias; }