提交 09e92cfd authored 作者: noelgrandin's avatar noelgrandin

Issue 531: IDENTITY ignored for added column

上级 04988d3e
......@@ -20,6 +20,7 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul><li>Follow JDBC specification on Procedures MetaData, use P0 as
return type of procedure.
</li><li>Issue 531: IDENTITY ignored for added column
</li></ul>
<h2>Version 1.4.178 Beta (2014-05-02)</h2>
......
......@@ -153,7 +153,11 @@ public class AlterTableAlterColumn extends SchemaCommand {
break;
}
for (Column column : columnsToAdd) {
convertAutoIncrementColumn(column);
if (column.isAutoIncrement()) {
int objId = getObjectId();
column.convertAutoIncrementToSequence(session, getSchema(), objId,
table.isTemporary());
}
}
copyData();
break;
......
......@@ -41,6 +41,7 @@ public class TestAlter extends TestBase {
testAlterTableDropColumnWithReferences();
testAlterTableAlterColumnWithConstraint();
testAlterTableAlterColumn();
testAlterTableAddColumnIdentity();
testAlterTableDropIdentityColumn();
testAlterTableAddColumnIfNotExists();
testAlterTableAddMultipleColumns();
......@@ -154,6 +155,20 @@ public class TestAlter extends TestBase {
stat.execute("drop table t");
}
private void testAlterTableAddColumnIdentity() throws SQLException {
stat.execute("create table t(x varchar)");
stat.execute("alter table t add id bigint identity(5, 5) not null");
stat.execute("insert into t values (null, null)");
stat.execute("insert into t values (null, null)");
ResultSet rs = stat.executeQuery("select id from t order by id");
assertTrue(rs.next());
assertEquals(5, rs.getInt(1));
assertTrue(rs.next());
assertEquals(10, rs.getInt(1));
assertFalse(rs.next());
stat.execute("drop table t");
}
private void testAlterTableAddColumnIfNotExists() throws SQLException {
stat.execute("create table t(x varchar) as select 'x'");
stat.execute("alter table t add if not exists x int");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论