提交 c3c3db15 authored 作者: Thomas Mueller's avatar Thomas Mueller

Allow index definition in CREATE TABLE.

上级 252aa246
...@@ -4983,11 +4983,13 @@ public class Parser { ...@@ -4983,11 +4983,13 @@ public class Parser {
private DefineCommand parseAlterTableAddConstraintIf(String tableName, Schema schema) { private DefineCommand parseAlterTableAddConstraintIf(String tableName, Schema schema) {
String constraintName = null, comment = null; String constraintName = null, comment = null;
boolean ifNotExists = false; boolean ifNotExists = false;
boolean allowIndexDefinition = database.getMode().indexDefinitionInCreateTable;
if (readIf("CONSTRAINT")) { if (readIf("CONSTRAINT")) {
ifNotExists = readIfNoExists(); ifNotExists = readIfNoExists();
constraintName = readIdentifierWithSchema(schema.getName()); constraintName = readIdentifierWithSchema(schema.getName());
checkSchema(schema); checkSchema(schema);
comment = readCommentIf(); comment = readCommentIf();
allowIndexDefinition = true;
} }
if (readIf("PRIMARY")) { if (readIf("PRIMARY")) {
read("KEY"); read("KEY");
...@@ -5006,7 +5008,7 @@ public class Parser { ...@@ -5006,7 +5008,7 @@ public class Parser {
command.setIndex(getSchema().findIndex(session, indexName)); command.setIndex(getSchema().findIndex(session, indexName));
} }
return command; return command;
} else if (database.getMode().indexDefinitionInCreateTable && (readIf("INDEX") || readIf("KEY"))) { } else if (allowIndexDefinition && (readIf("INDEX") || readIf("KEY"))) {
// MySQL // MySQL
CreateIndex command = new CreateIndex(session, schema); CreateIndex command = new CreateIndex(session, schema);
command.setComment(comment); command.setComment(comment);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论