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

AUTO_INCREMENT now works in the same way in ALTER TABLE ALTER COLUMN as in…

AUTO_INCREMENT now works in the same way in ALTER TABLE ALTER COLUMN as in CREATE TABLE (it does not create a primary key).
上级 c7f8a6bf
......@@ -152,13 +152,13 @@ public class AlterTableAlterColumn extends SchemaCommand {
} else if (!oldColumn.isNullable() && newColumn.isNullable()) {
checkNullable();
}
convertToIdentityIfRequired(newColumn);
convertAutoIncrementColumn(newColumn);
copyData();
break;
}
case ADD: {
checkNoViews();
convertToIdentityIfRequired(newColumn);
convertAutoIncrementColumn(newColumn);
copyData();
break;
}
......@@ -184,9 +184,14 @@ public class AlterTableAlterColumn extends SchemaCommand {
return 0;
}
private void convertToIdentityIfRequired(Column c) {
private void convertAutoIncrementColumn(Column c) throws SQLException {
if (c.isAutoIncrement()) {
c.setOriginalSQL("IDENTITY");
if (c.isPrimaryKey()) {
c.setOriginalSQL("IDENTITY");
} else {
int objId = getObjectId(true, true);
c.convertAutoIncrementToSequence(session, getSchema(), objId, table.isTemporary());
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论