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

Computed columns could not refer to itself.

上级 489f7c63
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Comparison with "x = all(select ...)" or similar returned the wrong result for some cases
<ul><li>Computed columns could not refer to itself.
</li><li>Comparison with "x = all(select ...)" or similar returned the wrong result for some cases
(for example if the subquery returned no rows, or multiple rows with the same value, or null, or if x was null).
</li><li>Issue 335: Could not run DROP ALL OBJECTS DELETE FILES on older databases with CLOB or BLOB data.
The problem was that the metadata table was not locked in some cases, so that
......
......@@ -266,7 +266,9 @@ public class ExpressionColumn extends Expression {
case ExpressionVisitor.NOT_FROM_RESOLVER:
return columnResolver != visitor.getResolver();
case ExpressionVisitor.GET_DEPENDENCIES:
visitor.addDependency(column.getTable());
if (column != null) {
visitor.addDependency(column.getTable());
}
return true;
case ExpressionVisitor.GET_COLUMNS:
visitor.addColumn(column);
......
......@@ -35,6 +35,7 @@ public class TestAlter extends TestBase {
deleteDb("alter");
conn = getConnection("alter");
stat = conn.createStatement();
testAlterTableAlterColumnAsSelfColumn();
testAlterTableDropColumnWithReferences();
testAlterTableAlterColumn();
testAlterTableDropIdentityColumn();
......@@ -43,8 +44,18 @@ public class TestAlter extends TestBase {
deleteDb("alter");
}
private void testAlterTableDropColumnWithReferences() throws SQLException {
private void testAlterTableAlterColumnAsSelfColumn() throws SQLException {
stat.execute("create table test(id int, name varchar)");
stat.execute("alter table test alter column id int as id+1");
stat.execute("insert into test values(1, 'Hello')");
stat.execute("update test set name='World'");
ResultSet rs = stat.executeQuery("select * from test");
rs.next();
assertEquals(3, rs.getInt(1));
stat.execute("drop table test");
}
private void testAlterTableDropColumnWithReferences() throws SQLException {
stat.execute("create table parent(id int, b int)");
stat.execute("create table child(p int primary key)");
stat.execute("alter table child add foreign key(p) references parent(id)");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论