mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved mysql create table parser. for fulltext key, for issue #2271
This commit is contained in:
+16
-4
@@ -41,10 +41,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSubPartitionByList;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLCreateTableParser;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
import com.alibaba.druid.sql.parser.*;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
@@ -109,6 +106,21 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
stmt.setSelect(query);
|
||||
} else {
|
||||
for (;;) {
|
||||
if (lexer.identifierEquals(FnvHash.Constants.FULLTEXT)) {
|
||||
Lexer.SavePoint mark = lexer.mark();
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.KEY) {
|
||||
MySqlKey fulltextKey = (MySqlKey) parseConstraint();
|
||||
fulltextKey.setIndexType("FULLTEXT");
|
||||
stmt.getTableElementList().add(fulltextKey);
|
||||
if (lexer.token() == Token.RPAREN) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
lexer.reset(mark);
|
||||
}
|
||||
}
|
||||
|
||||
SQLColumnDefinition column = null;
|
||||
if (lexer.token() == Token.IDENTIFIER //
|
||||
|| lexer.token() == Token.LITERAL_CHARS) {
|
||||
|
||||
@@ -632,5 +632,6 @@ public final class FnvHash {
|
||||
long EXIST = fnv1a_64_lower("EXIST");
|
||||
|
||||
long TBLPROPERTIES = fnv1a_64_lower("TBLPROPERTIES");
|
||||
long FULLTEXT = fnv1a_64_lower("FULLTEXT");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user