提交 2dabe8a4 authored 作者: noelgrandin's avatar noelgrandin

Fix NPE when attempting to add foreign key reference to Table View.

上级 77bc4eec
......@@ -48,6 +48,7 @@ Change Log
</li><li>Add support for in-memory spatial index.
</li><li>change the PageStore#changeCount field from an int to a long,
to cope with databases with very high transaction rates.
</li><li>Fix NPE when attempting to add foreign key reference to Table View.
</li></ul>
<h2>Version 1.3.172 (2013-05-25)</h2>
......
......@@ -378,6 +378,11 @@ public class TableView extends Table {
return item.getIndex();
}
@Override
public boolean canReference() {
return false;
}
@Override
public ArrayList<Index> getIndexes() {
return null;
......
......@@ -23,7 +23,7 @@ public class TestView extends TestBase {
/**
* Run just this test.
*
*
* @param a ignored
*/
public static void main(String... a) throws Exception {
......@@ -41,6 +41,7 @@ public class TestView extends TestBase {
testInSelect();
testUnionReconnect();
testManyViews();
testReferenceView();
deleteDb("view");
}
......@@ -83,8 +84,8 @@ public class TestView extends TestBase {
// assertTrue(rs.next());
// assertFalse(rs.next());
// rs = stat.executeQuery("select VIEW_DEFINITION " +
// "from information_schema.views " +
// "where TABLE_NAME='TEST_VIEW'");
// "from information_schema.views " +
// "where TABLE_NAME='TEST_VIEW'");
// rs.next();
// assertEquals("...", rs.getString(1));
conn.close();
......@@ -112,7 +113,7 @@ public class TestView extends TestBase {
/**
* This method is called via reflection from the database.
*
*
* @return the static value x
*/
public static int getX() {
......@@ -192,4 +193,16 @@ public class TestView extends TestBase {
conn.close();
deleteDb("view");
}
private void testReferenceView() throws SQLException {
deleteDb("view");
Connection conn = getConnection("view");
Statement s = conn.createStatement();
s.execute("create table t0(id int primary key)");
s.execute("create view t1 as select * from t0");
assertThrows(50100, s).execute(
"create table t2(id int primary key, col1 int not null, foreign key (col1) references t1(id))");
conn.close();
deleteDb("view");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论