private ArrayList<String> readDerivedColumnNames() { if (readIf("(")) { ArrayList<String> derivedColumnNames = New.arrayList(); do { derivedColumnNames.add(readAliasIdentifier()); } while (readIfMore(true)); return derivedColumnNames; } return null; }
private boolean readIfExists(boolean ifExists) { if (readIf("IF")) { read("EXISTS"); ifExists = true; } return ifExists; }
private ArrayList<String> readTableEngineParams() { ArrayList<String> tableEngineParams = New.arrayList(); do { tableEngineParams.add(readUniqueIdentifier()); } while (readIf(",")); return tableEngineParams; }
private boolean readIfNotExists() { if (readIf("IF")) { read("NOT"); read("EXISTS"); return true; } return false; }
private TransactionCommand parseCheckpoint() { TransactionCommand command; if (readIf("SYNC")) { command = new TransactionCommand(session, CommandInterface.CHECKPOINT_SYNC); } else { command = new TransactionCommand(session, CommandInterface.CHECKPOINT); } return command; }
private Prepared parseReleaseSavepoint() { Prepared command = new NoOperation(session); readIf("SAVEPOINT"); readUniqueIdentifier(); return command; }
private Expression readExpression() { Expression r = readAnd(); while (readIf("OR")) { r = new ConditionAndOr(ConditionAndOr.OR, r, readAnd()); } return r; }
private Expression readAnd() { Expression r = readCondition(); while (readIf("AND")) { r = new ConditionAndOr(ConditionAndOr.AND, r, readCondition()); } return r; }
private String readFromAlias(String alias, List<String> excludeIdentifiers) { if (readIf("AS")) { alias = readAliasIdentifier(); } else if (currentTokenType == IDENTIFIER && !isTokenInList(excludeIdentifiers)) { alias = readAliasIdentifier(); } return alias; }
private void parseDeleteGivenTable(Delete command, Expression limit, int start) { if (readIf("WHERE")) { Expression condition = readExpression(); command.setCondition(condition); } if (readIf("LIMIT") && limit == null) { limit = readTerm().optimize(session); } command.setLimit(limit); setSQL(command, "DELETE", start); }
private DeallocateProcedure parseDeallocate() { readIf("PLAN"); String procedureName = readAliasIdentifier(); DeallocateProcedure command = new DeallocateProcedure(session); command.setProcedureName(procedureName); return command; }
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") || isToken("WITH"); parseIndex = start; read(); return select; }
private void parseSelectSimpleFromPart(Select command) { do { TableFilter filter = readTableFilter(); parseJoinTableFilter(filter, command); } while (readIf(",")); // Parser can reorder joined table filters, need to explicitly sort them // to get the order as it was in the original query. if (session.isForceJoinOrder()) { sortTableFilters(command.getTopFilters()); } }