提交 8c639ee4 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Throw COLUMN_IS_REFERENCED_1 instead of VIEW_IS_INVALID_2 from DROP COLUMN

上级 8f3a8e36
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Issue #1475: Dropping column used by a view produces misleading error message
</li>
<li>Issue #1473: TestScript needs better detection of sorted result
</li>
<li>PR #1471: issue 1350: TestCrashAPI: PageStore.freeListPagesPerList
......
......@@ -297,7 +297,7 @@ public class AlterTableAlterColumn extends CommandWithColumns {
checkViews(table, newTable);
} catch (DbException e) {
execute("DROP TABLE " + newTable.getName(), true);
throw DbException.get(ErrorCode.VIEW_IS_INVALID_2, e, getSQL(), e.getMessage());
throw e;
}
String tableName = table.getName();
ArrayList<TableView> dependentViews = new ArrayList<>(table.getDependentViews());
......@@ -547,7 +547,11 @@ public class AlterTableAlterColumn extends CommandWithColumns {
// check if the query is still valid
// do not execute, not even with limit 1, because that could
// have side effects or take a very long time
session.prepare(sql);
try {
session.prepare(sql);
} catch (DbException e) {
throw DbException.get(ErrorCode.COLUMN_IS_REFERENCED_1, e, view.getSQL());
}
checkViewsAreValid(view);
}
}
......
......@@ -78,3 +78,21 @@ SELECT * FROM TEST;
DROP TABLE TEST;
> ok
CREATE TABLE T1(ID INT PRIMARY KEY, C INT);
> ok
CREATE VIEW V1 AS SELECT C FROM T1;
> ok
ALTER TABLE T1 DROP COLUMN C;
> exception COLUMN_IS_REFERENCED_1
DROP VIEW V1;
> ok
ALTER TABLE T1 DROP COLUMN C;
> ok
DROP TABLE T1;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论