Fix a problem with the way temporary tables mask permanent tables. (CVS 345)
FossilOrigin-Name: ba89da603135e5f63f6f97ba3adad02682375c07
This commit is contained in:
+104
-33
@@ -12,7 +12,7 @@
|
||||
#
|
||||
# This file implements tests for temporary tables and indices.
|
||||
#
|
||||
# $Id: temptable.test,v 1.3 2001/10/09 12:39:24 drh Exp $
|
||||
# $Id: temptable.test,v 1.4 2002/01/10 14:31:49 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -148,11 +148,11 @@ do_test temptable-3.4 {
|
||||
# hides the existance of the permanent table.
|
||||
#
|
||||
do_test temptable-4.1 {
|
||||
db2 eval {
|
||||
execsql {
|
||||
CREATE TEMP TABLE t2(x,y);
|
||||
INSERT INTO t2 VALUES(10,20);
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} db2
|
||||
} {10 20}
|
||||
do_test temptable-4.2 {
|
||||
execsql {
|
||||
@@ -162,68 +162,139 @@ do_test temptable-4.2 {
|
||||
}
|
||||
} {9 8 7}
|
||||
do_test temptable-4.3 {
|
||||
set r [catch {db2 eval {SELECT * FROM t2}} msg]
|
||||
lappend r $msg
|
||||
catchsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {1 {database schema has changed}}
|
||||
do_test temptable-4.4 {
|
||||
set r [catch {db2 eval {SELECT * FROM t2}} msg]
|
||||
lappend r $msg
|
||||
catchsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {0 {10 20}}
|
||||
do_test temptable-4.5 {
|
||||
db2 eval {DROP TABLE t2}
|
||||
set r [catch {db2 eval {SELECT * FROM t2}} msg]
|
||||
lappend r $msg
|
||||
catchsql {
|
||||
DROP TABLE t2;
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {1 {no such table: t2}}
|
||||
do_test temptable-4.6 {
|
||||
db2 close
|
||||
sqlite db2 ./test.db
|
||||
set r [catch {db2 eval {SELECT * FROM t2}} msg]
|
||||
lappend r $msg
|
||||
catchsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {0 {9 8 7}}
|
||||
do_test temptable-4.7 {
|
||||
catchsql {
|
||||
DROP TABLE t2;
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {1 {no such table: t2}}
|
||||
do_test temptable-4.8 {
|
||||
db2 close
|
||||
sqlite db2 ./test.db
|
||||
execsql {
|
||||
CREATE TEMP TABLE t2(x unique,y);
|
||||
INSERT INTO t2 VALUES(1,2);
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {1 2}
|
||||
do_test temptable-4.9 {
|
||||
execsql {
|
||||
CREATE TABLE t2(x unique, y);
|
||||
INSERT INTO t2 VALUES(3,4);
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {3 4}
|
||||
do_test temptable-4.10 {
|
||||
catchsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {1 {database schema has changed}}
|
||||
do_test temptable-4.11 {
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {1 2}
|
||||
do_test temptable-4.12 {
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {3 4}
|
||||
do_test temptable-4.13 {
|
||||
catchsql {
|
||||
DROP TABLE t2;
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {1 {no such table: t2}}
|
||||
do_test temptable-4.14 {
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {3 4}
|
||||
do_test temptable-4.15 {
|
||||
db2 close
|
||||
sqlite db2 ./test.db
|
||||
execsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {3 4}
|
||||
|
||||
# Now create a temporary table in db2 and a permanent index in db. The
|
||||
# temporary table in db2 should mask the name of the permanent index,
|
||||
# but the permanent index should still be accessible and should still
|
||||
# be updated when its correspnding table changes.
|
||||
# be updated when its corresponding table changes.
|
||||
#
|
||||
do_test temptable-5.1 {
|
||||
db2 eval {CREATE TEMP TABLE mask(a,b,c)}
|
||||
execsql {
|
||||
CREATE TEMP TABLE mask(a,b,c)
|
||||
} db2
|
||||
execsql {
|
||||
CREATE INDEX mask ON t2(x);
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {9 8 7}
|
||||
} {3 4}
|
||||
do_test temptable-5.2 {
|
||||
set r [catch {db2 eval {SELECT * FROM t2}} msg]
|
||||
lappend r $msg
|
||||
catchsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {1 {database schema has changed}}
|
||||
do_test temptable-5.3 {
|
||||
set r [catch {db2 eval {SELECT * FROM t2}} msg]
|
||||
lappend r $msg
|
||||
} {0 {9 8 7}}
|
||||
catchsql {
|
||||
SELECT * FROM t2;
|
||||
} db2
|
||||
} {0 {3 4}}
|
||||
do_test temptable-5.4 {
|
||||
execsql {SELECT y FROM t2 WHERE x=9}
|
||||
} {8}
|
||||
do_test temptable-5.5 {
|
||||
db2 eval {SELECT y FROM t2 WHERE x=9}
|
||||
} {8}
|
||||
do_test temptable-5.6 {
|
||||
db2 eval {
|
||||
INSERT INTO t2 VALUES(1,2,3);
|
||||
SELECT y FROM t2 WHERE x=1;
|
||||
execsql {
|
||||
SELECT y FROM t2 WHERE x=3
|
||||
}
|
||||
} {4}
|
||||
do_test temptable-5.5 {
|
||||
execsql {
|
||||
SELECT y FROM t2 WHERE x=3
|
||||
} db2
|
||||
} {4}
|
||||
do_test temptable-5.6 {
|
||||
execsql {
|
||||
INSERT INTO t2 VALUES(1,2);
|
||||
SELECT y FROM t2 WHERE x=1;
|
||||
} db2
|
||||
} {2}
|
||||
do_test temptable-5.7 {
|
||||
db2 eval {SELECT y FROM t2 WHERE x=9}
|
||||
} {8}
|
||||
execsql {
|
||||
SELECT y FROM t2 WHERE x=3
|
||||
} db2
|
||||
} {4}
|
||||
do_test temptable-5.8 {
|
||||
execsql {
|
||||
SELECT y FROM t2 WHERE x=1;
|
||||
}
|
||||
} {2}
|
||||
do_test temptable-5.9 {
|
||||
execsql {SELECT y FROM t2 WHERE x=9}
|
||||
} {8}
|
||||
execsql {
|
||||
SELECT y FROM t2 WHERE x=3
|
||||
}
|
||||
} {4}
|
||||
|
||||
db2 close
|
||||
|
||||
|
||||
+9
-3
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is database locks.
|
||||
#
|
||||
# $Id: trans.test,v 1.9 2002/01/09 13:30:42 drh Exp $
|
||||
# $Id: trans.test,v 1.10 2002/01/10 14:31:49 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@@ -646,13 +646,19 @@ do_test trans-6.36 {
|
||||
SELECT * FROM t1 WHERE c<1;
|
||||
}
|
||||
} {4 -5 -6 1 -2 -3}
|
||||
do_test trans-6.36 {
|
||||
do_test trans-6.37 {
|
||||
execsql {
|
||||
DROP INDEX i1;
|
||||
SELECT * FROM t1 WHERE c<1;
|
||||
}
|
||||
} {1 -2 -3 4 -5 -6}
|
||||
do_test trans-6.38 {
|
||||
execsql {
|
||||
ROLLBACK;
|
||||
SELECT * FROM t1 WHERE b<1;
|
||||
}
|
||||
} {4 -5 -6 1 -2 -3}
|
||||
do_test trans-6.38 {
|
||||
do_test trans-6.39 {
|
||||
execsql {
|
||||
SELECT * FROM t1 WHERE c<1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user