提交 0677dc95 authored 作者: Thomas Mueller's avatar Thomas Mueller

support MySQL auto_increment with different primary key

上级 9d0b4297
......@@ -3049,6 +3049,7 @@ public class Parser {
column = new Column(columnName, Value.LONG);
column.setOriginalSQL("IDENTITY");
parseAutoIncrement(column);
column.setPrimaryKey(true);
} else {
column = parseColumn(columnName);
}
......@@ -3087,6 +3088,7 @@ public class Parser {
}
read(")");
}
column.setPrimaryKey(true);
column.setAutoIncrement(true, start, increment);
}
if (readIf("NOT")) {
......@@ -3095,11 +3097,17 @@ public class Parser {
} else {
readIf("NULL");
}
if (readIf("AUTO_INCREMENT") || readIf("IDENTITY")) {
if (readIf("AUTO_INCREMENT")) {
parseAutoIncrement(column);
if (readIf("NOT")) {
read("NULL");
}
} else if (readIf("IDENTITY")) {
parseAutoIncrement(column);
column.setPrimaryKey(true);
if (readIf("NOT")) {
read("NULL");
}
}
if (readIf("NULL_TO_DEFAULT")) {
column.setConvertNullToDefault(true);
......@@ -4409,7 +4417,8 @@ public class Parser {
} else {
String columnName = readColumnIdentifier();
Column column = parseColumnForTable(columnName);
if (column.getAutoIncrement()) {
if (column.getAutoIncrement() && column.getPrimaryKey()) {
column.setPrimaryKey(false);
IndexColumn[] cols = new IndexColumn[]{new IndexColumn()};
cols[0].columnName = column.getName();
AlterTableAddConstraint pk = new AlterTableAddConstraint(session, schema);
......
......@@ -538,4 +538,8 @@ public class Column {
return true;
}
public boolean getPrimaryKey() {
return primaryKey;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论