lexer.nextToken();
if (lexer.token() == Token.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) {
SQLAlterTableAddIndex item = parseAlterTableAddIndex();
item.setParent(stmt);
stmt.getItems().add(item);
} else if (lexer.token() == Token.UNIQUE) {
SQLAlterTableAddIndex item = parseAlterTableAddIndex();
item.setParent(stmt);
stmt.getItems().add(item);
} else if (lexer.token() == Token.PRIMARY) {
SQLPrimaryKey primaryKey = this.exprParser.parsePrimaryKey();
SQLAlterTableAddConstraint item = new SQLAlterTableAddConstraint(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);
SQLAlterTableAddConstraint item = new SQLAlterTableAddConstraint(primaryKey);
item.setParent(stmt);
stmt.getItems().add(item);
} else if (lexer.token() == Token.FOREIGN) {
MysqlForeignKey fk = this.getExprParser().parseForeignKey();
fk.setName(constraintName);
fk.setHasConstraint(true);
SQLAlterTableAddConstraint item = new SQLAlterTableAddConstraint(fk);
item.setParent(stmt);
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 (lexer.token() == Token.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();