lexer.nextToken();
if (identifierEquals("COLUMN")) {
lexer.nextToken();
MySqlAlterTableAddColumn item = new MySqlAlterTableAddColumn();
SQLColumnDefinition columnDef = this.exprParser.parseColumn();
item.getColumns().add(columnDef);
if (identifierEquals("AFTER")) {
lexer.nextToken();
item.setAfterColumn(this.exprParser.name());
} else if (identifierEquals("FIRST")) {
lexer.nextToken();
if (lexer.token() == Token.IDENTIFIER) {
item.setFirstColumn(this.exprParser.name());
} else {
item.setFirst(true);
}
}
stmt.getItems().add(item);
} else if (lexer.token() == Token.INDEX) {
lexer.nextToken();
MySqlAlterTableAddIndex item = new MySqlAlterTableAddIndex();
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
} else {
item.setName(this.exprParser.name());
accept(Token.LPAREN);
}
for (;;) {
SQLSelectOrderByItem column = this.exprParser.parseSelectOrderByItem();
item.getItems().add(column);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
break;
}
accept(Token.RPAREN);
stmt.getItems().add(item);
} else if (lexer.token() == Token.UNIQUE) {
lexer.nextToken();
if (lexer.token() == Token.INDEX) {
lexer.nextToken();
}
MySqlAlterTableAddUnique item = new MySqlAlterTableAddUnique();
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
} else {
item.setName(this.exprParser.name());
accept(Token.LPAREN);
}
for (;;) {
SQLSelectOrderByItem column = this.exprParser.parseSelectOrderByItem();
item.getItems().add(column);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
break;
}
accept(Token.RPAREN);
stmt.getItems().add(item);
} else if (lexer.token() == Token.PRIMARY) {
SQLPrimaryKey primaryKey = ((MySqlExprParser) this.exprParser).parsePrimaryKey();
SQLAlterTableAddPrimaryKey item = new SQLAlterTableAddPrimaryKey();
item.setPrimaryKey(primaryKey);
stmt.getItems().add(item);
} else if (lexer.token() == Token.KEY) {
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
} else if (lexer.token() == Token.CONSTRAINT) {
lexer.nextToken();
SQLName constraintName = this.exprParser.name();
if (lexer.token() == Token.PRIMARY) {
SQLPrimaryKey primaryKey = ((MySqlExprParser) this.exprParser).parsePrimaryKey();
primaryKey.setName(constraintName);
SQLAlterTableAddPrimaryKey item = new SQLAlterTableAddPrimaryKey();
item.setPrimaryKey(primaryKey);
stmt.getItems().add(item);
} else {
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
}
} else if (identifierEquals(FULLTEXT)) {
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
} else if (identifierEquals(SPATIAL)) {
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
} else {
MySqlAlterTableAddColumn item = new MySqlAlterTableAddColumn();
SQLColumnDefinition columnDef = this.exprParser.parseColumn();
item.getColumns().add(columnDef);
if (identifierEquals("AFTER")) {
lexer.nextToken();
item.setAfterColumn(this.exprParser.name());
}
stmt.getItems().add(item);
}
} else if (lexer.token() == Token.ALTER) {
lexer.nextToken();
if (identifierEquals("COLUMN")) {
lexer.nextToken();
}
SQLAlterTableAlterColumn alterColumn = new SQLAlterTableAlterColumn();
SQLColumnDefinition columnDef = this.exprParser.parseColumn();
alterColumn.setColumn(columnDef);
stmt.getItems().add(alterColumn);
} else if (identifierEquals("CHANGE")) {
lexer.nextToken();