提交 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 ...@@ -48,6 +48,7 @@ Change Log
</li><li>Add support for in-memory spatial index. </li><li>Add support for in-memory spatial index.
</li><li>change the PageStore#changeCount field from an int to a long, </li><li>change the PageStore#changeCount field from an int to a long,
to cope with databases with very high transaction rates. 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> </li></ul>
<h2>Version 1.3.172 (2013-05-25)</h2> <h2>Version 1.3.172 (2013-05-25)</h2>
......
...@@ -378,6 +378,11 @@ public class TableView extends Table { ...@@ -378,6 +378,11 @@ public class TableView extends Table {
return item.getIndex(); return item.getIndex();
} }
@Override
public boolean canReference() {
return false;
}
@Override @Override
public ArrayList<Index> getIndexes() { public ArrayList<Index> getIndexes() {
return null; return null;
......
...@@ -23,7 +23,7 @@ public class TestView extends TestBase { ...@@ -23,7 +23,7 @@ public class TestView extends TestBase {
/** /**
* Run just this test. * Run just this test.
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String... a) throws Exception { public static void main(String... a) throws Exception {
...@@ -41,6 +41,7 @@ public class TestView extends TestBase { ...@@ -41,6 +41,7 @@ public class TestView extends TestBase {
testInSelect(); testInSelect();
testUnionReconnect(); testUnionReconnect();
testManyViews(); testManyViews();
testReferenceView();
deleteDb("view"); deleteDb("view");
} }
...@@ -83,8 +84,8 @@ public class TestView extends TestBase { ...@@ -83,8 +84,8 @@ public class TestView extends TestBase {
// assertTrue(rs.next()); // assertTrue(rs.next());
// assertFalse(rs.next()); // assertFalse(rs.next());
// rs = stat.executeQuery("select VIEW_DEFINITION " + // rs = stat.executeQuery("select VIEW_DEFINITION " +
// "from information_schema.views " + // "from information_schema.views " +
// "where TABLE_NAME='TEST_VIEW'"); // "where TABLE_NAME='TEST_VIEW'");
// rs.next(); // rs.next();
// assertEquals("...", rs.getString(1)); // assertEquals("...", rs.getString(1));
conn.close(); conn.close();
...@@ -112,7 +113,7 @@ public class TestView extends TestBase { ...@@ -112,7 +113,7 @@ public class TestView extends TestBase {
/** /**
* This method is called via reflection from the database. * This method is called via reflection from the database.
* *
* @return the static value x * @return the static value x
*/ */
public static int getX() { public static int getX() {
...@@ -192,4 +193,16 @@ public class TestView extends TestBase { ...@@ -192,4 +193,16 @@ public class TestView extends TestBase {
conn.close(); conn.close();
deleteDb("view"); 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论