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

Trying to alter a temporary table threw a strange exception.

上级 50769a54
...@@ -213,6 +213,9 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -213,6 +213,9 @@ public class AlterTableAlterColumn extends SchemaCommand {
} }
private void copyData() throws SQLException { private void copyData() throws SQLException {
if (table.isTemporary()) {
throw Message.getUnsupportedException("TEMP TABLE");
}
Database db = session.getDatabase(); Database db = session.getDatabase();
String tempName = db.getTempTableName(session.getId()); String tempName = db.getTempTableName(session.getId());
Column[] columns = table.getColumns(); Column[] columns = table.getColumns();
......
...@@ -10,7 +10,6 @@ import java.sql.Connection; ...@@ -10,7 +10,6 @@ import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
...@@ -30,6 +29,7 @@ public class TestTempTables extends TestBase { ...@@ -30,6 +29,7 @@ public class TestTempTables extends TestBase {
public void test() throws SQLException { public void test() throws SQLException {
deleteDb("tempTables"); deleteDb("tempTables");
Connection c1 = getConnection("tempTables"); Connection c1 = getConnection("tempTables");
testAlter(c1);
Connection c2 = getConnection("tempTables"); Connection c2 = getConnection("tempTables");
testConstraints(c1, c2); testConstraints(c1, c2);
testTables(c1, c2); testTables(c1, c2);
...@@ -39,6 +39,23 @@ public class TestTempTables extends TestBase { ...@@ -39,6 +39,23 @@ public class TestTempTables extends TestBase {
deleteDb("tempTables"); deleteDb("tempTables");
} }
private void testAlter(Connection conn) throws SQLException {
Statement stat;
stat = conn.createStatement();
stat.execute("create temporary table test(id varchar)");
stat.execute("create index idx1 on test(id)");
stat.execute("drop index idx1");
stat.execute("create index idx1 on test(id)");
stat.execute("insert into test select x from system_range(1, 10)");
try {
stat.execute("alter table test add column x int");
fail();
} catch (SQLException e) {
assertKnownException(e);
}
stat.execute("drop table test");
}
private void testConstraints(Connection conn1, Connection conn2) throws SQLException { private void testConstraints(Connection conn1, Connection conn2) throws SQLException {
Statement s1 = conn1.createStatement(), s2 = conn2.createStatement(); Statement s1 = conn1.createStatement(), s2 = conn2.createStatement();
s1.execute("create local temporary table test(id int unique)"); s1.execute("create local temporary table test(id int unique)");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论