use of com.alibaba.cobar.parser.ast.stmt.dal.DALSetCharacterSetStatement in project cobar by alibaba.
the class MySQLDALParser method set.
/**
* @return {@link DALSetStatement} or {@link MTSSetTransactionStatement}
*/
@SuppressWarnings("unchecked")
public SQLStatement set() throws SQLSyntaxErrorException {
match(KW_SET);
if (lexer.token() == KW_OPTION) {
lexer.nextToken();
}
if (lexer.token() == IDENTIFIER && SpecialIdentifier.NAMES == specialIdentifiers.get(lexer.stringValueUppercase())) {
if (lexer.nextToken() == KW_DEFAULT) {
lexer.nextToken();
return new DALSetNamesStatement();
}
String charsetName = getStringValue();
String collationName = null;
if (lexer.token() == KW_COLLATE) {
lexer.nextToken();
collationName = getStringValue();
}
return new DALSetNamesStatement(charsetName, collationName);
} else if (lexer.token() == KW_CHARACTER) {
lexer.nextToken();
match(KW_SET);
if (lexer.token() == KW_DEFAULT) {
lexer.nextToken();
return new DALSetCharacterSetStatement();
}
String charsetName = getStringValue();
return new DALSetCharacterSetStatement(charsetName);
}
List<Pair<VariableExpression, Expression>> assignmentList;
Object obj = varAssign();
if (obj instanceof MTSSetTransactionStatement) {
return (MTSSetTransactionStatement) obj;
}
Pair<VariableExpression, Expression> pair = (Pair<VariableExpression, Expression>) obj;
if (lexer.token() != PUNC_COMMA) {
assignmentList = new ArrayList<Pair<VariableExpression, Expression>>(1);
assignmentList.add(pair);
return new DALSetStatement(assignmentList);
}
assignmentList = new LinkedList<Pair<VariableExpression, Expression>>();
assignmentList.add(pair);
for (; lexer.token() == PUNC_COMMA; ) {
lexer.nextToken();
pair = (Pair<VariableExpression, Expression>) varAssign();
assignmentList.add(pair);
}
return new DALSetStatement(assignmentList);
}
Aggregations