use of com.alibaba.cobar.parser.ast.fragment.ddl.index.IndexOption in project cobar by alibaba.
the class MySQLDDLParser method indexDefinition.
// col_name column_definition
// | [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...)
// [index_option] ...
// | {INDEX|KEY} [index_name] [index_type] (index_col_name,...)
// [index_option] ...
// | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] [index_type]
// (index_col_name,...) [index_option] ...
// | {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...)
// [index_option] ...
// | [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...)
// reference_definition
// | CHECK (expr)
private IndexDefinition indexDefinition() throws SQLSyntaxErrorException {
IndexDefinition.IndexType indexType = null;
List<IndexColumnName> columns = new ArrayList<IndexColumnName>(1);
if (lexer.token() == KW_USING) {
lexer.nextToken();
int tp = matchIdentifier("BTREE", "HASH");
indexType = tp == 0 ? IndexDefinition.IndexType.BTREE : IndexDefinition.IndexType.HASH;
}
match(PUNC_LEFT_PAREN);
for (int i = 0; lexer.token() != PUNC_RIGHT_PAREN; ++i) {
if (i > 0)
match(PUNC_COMMA);
IndexColumnName indexColumnName = indexColumnName();
columns.add(indexColumnName);
}
match(PUNC_RIGHT_PAREN);
List<IndexOption> options = indexOptions();
return new IndexDefinition(indexType, columns, options);
}
Aggregations