else {
tokenizer.back();
}
// parse column list
HsqlArrayList vcolumn = new HsqlArrayList();
do {
int expPos = tokenizer.getPosition();
Expression e = parseExpression();
if (isCompilingView()) {
if (e.getType() == Expression.ASTERISK) {
if (select.asteriskPositions == null) {
select.asteriskPositions = new IntKeyHashMap();
}
// remember the position of the asterisk. For the moment, just
// remember the expression, so it can later be found and replaced
// with the concrete column list
select.asteriskPositions.put(expPos, e);
}
}
token = tokenizer.getString();
if (tokenizer.wasThis(Token.T_AS)) {
e.setAlias(tokenizer.getSimpleName(),
tokenizer.wasQuotedIdentifier());
token = tokenizer.getString();
} else if (tokenizer.wasSimpleName()) {
e.setAlias(token, tokenizer.wasQuotedIdentifier());
token = tokenizer.getString();
}
vcolumn.add(e);
} while (tokenizer.wasThis(Token.T_COMMA));
if (token.equals(Token.T_INTO)) {
boolean getname = true;
token = tokenizer.getString();
select.intoType = database.getDefaultTableType();
if (tokenizer.wasSimpleToken()) {
switch (Token.get(token)) {
case Token.CACHED :
select.intoType = Table.CACHED_TABLE;
break;
case Token.TEMP :
select.intoType = Table.TEMP_TABLE;
break;
case Token.TEXT :
select.intoType = Table.TEXT_TABLE;
break;
case Token.MEMORY :
select.intoType = Table.MEMORY_TABLE;
break;
default :
getname = false;
break;
}
if (getname) {
token = tokenizer.getName();
}
}
if (!tokenizer.wasName()) {
tokenizer.throwUnexpected();
}
select.sIntoTable = database.nameManager.newHsqlName(token,
tokenizer.wasQuotedIdentifier());
select.sIntoTable.schema =
session.getSchemaHsqlName(tokenizer.getLongNameFirst());
token = tokenizer.getString();
}
tokenizer.matchThis(Token.T_FROM);
Expression condition = null;
// parse table list
HsqlArrayList vfilter = new HsqlArrayList();
vfilter.add(parseTableFilter(false));
while (true) {
token = tokenizer.getString();
boolean cross = false;
if (tokenizer.wasThis(Token.T_INNER)) {
tokenizer.getThis(Token.T_JOIN);
token = Token.T_JOIN;
} else if (tokenizer.wasThis(Token.T_CROSS)) {
tokenizer.getThis(Token.T_JOIN);
token = Token.T_JOIN;
cross = true;
}
if (token.equals(Token.T_LEFT)
&& !tokenizer.wasQuotedIdentifier()) {
tokenizer.isGetThis(Token.T_OUTER);
tokenizer.getThis(Token.T_JOIN);
TableFilter tf = parseTableFilter(true);
vfilter.add(tf);
tokenizer.getThis(Token.T_ON);
Expression newcondition = parseExpression();
newcondition.checkTables(vfilter);
condition = addJoinCondition(condition, newcondition, tf,
true);
// MarcH HuugO RIGHT JOIN SUPPORT
} else if (token.equals(Token.T_RIGHT)
&& !tokenizer.wasQuotedIdentifier()) {
tokenizer.isGetThis(Token.T_OUTER);
tokenizer.getThis(Token.T_JOIN);
// this object is not an outerjoin, the next object is an outerjoin
TableFilter tf = parseTableFilter(false);
// insert new condition as first element in a new vfilter (nvfilter), copy the content of vfilter and rename nvfilter back to vfilter.
HsqlArrayList nvfilter = new HsqlArrayList();
nvfilter.add(tf);
nvfilter.addAll(vfilter);
vfilter = nvfilter;
// set isOuterJoin correct
((TableFilter) vfilter.get(1)).isOuterJoin = true;