diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-02-17 17:25:57 +0000 |
|---|---|---|
| committer | <> | 2015-03-17 16:26:24 +0000 |
| commit | 780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch) | |
| tree | 598f8b9fa431b228d29897e798de4ac0c1d3d970 /lang/sql/sqlite/test/temptrigger.test | |
| parent | 7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff) | |
| download | berkeleydb-master.tar.gz | |
Diffstat (limited to 'lang/sql/sqlite/test/temptrigger.test')
| -rw-r--r-- | lang/sql/sqlite/test/temptrigger.test | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/lang/sql/sqlite/test/temptrigger.test b/lang/sql/sqlite/test/temptrigger.test index ececc4a8..551c6204 100644 --- a/lang/sql/sqlite/test/temptrigger.test +++ b/lang/sql/sqlite/test/temptrigger.test @@ -13,6 +13,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix temptrigger ifcapable {!trigger || !shared_cache} { finish_test ; return } @@ -157,8 +158,8 @@ sqlite3_enable_shared_cache $::enable_shared_cache # temptrigger-3.4: Check that the temp trigger can be dropped without error. # do_test temptrigger-3.1 { - catch { file delete -force test2.db test2.db-journal } - catch { file delete -force test.db test.db-journal } + catch { forcedelete test2.db test2.db-journal } + catch { forcedelete test.db test.db-journal } sqlite3 db test.db sqlite3 db2 test2.db execsql { CREATE TABLE t2(a, b) } db2 @@ -201,4 +202,78 @@ do_test temptrigger-3.4 { catch { db close } catch { db2 close } + +#------------------------------------------------------------------------- +# Test that creating a temp table after a temp trigger on the same name +# has been created is an error. +# +reset_db +do_execsql_test 4.0 { + CREATE TABLE t1(x); + CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN + SELECT 1,2,3; + END; +} + +do_execsql_test 4.1 { + CREATE TEMP TABLE t1(x); +} + +#------------------------------------------------------------------------- +# Test that no harm is done if the table a temp trigger is attached to is +# deleted by an external connection. +# +reset_db +do_execsql_test 5.0 { + CREATE TABLE t1(x); + CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN SELECT 1,2,3; END; +} + +do_test 5.1 { + sqlite3 db2 test.db + execsql { DROP TABLE t1 } db2 +} {} + +do_execsql_test 5.2 { + SELECT * FROM sqlite_master; + SELECT * FROM sqlite_temp_master; +} { + trigger tr1 t1 0 + {CREATE TRIGGER tr1 BEFORE INSERT ON t1 BEGIN SELECT 1,2,3; END} +} +db2 close + +#------------------------------------------------------------------------- +# Check that if a second connection creates a table in an attached database +# with the same name as a table in the main database that has a temp +# trigger attached to it nothing goes awry. +# +reset_db +forcedelete test.db2 + +do_execsql_test 6.0 { + CREATE TABLE t1(x); + CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN + SELECT raise(ABORT, 'error'); + END; + ATTACH 'test.db2' AS aux; +} + +do_test 6.1 { + sqlite3 db2 test.db2 + execsql { CREATE TABLE t1(a, b, c); } db2 +} {} + +do_execsql_test 6.2 { + SELECT type,name,tbl_name,sql FROM aux.sqlite_master; + INSERT INTO aux.t1 VALUES(1,2,3); +} { + table t1 t1 {CREATE TABLE t1(a, b, c)} +} + +do_catchsql_test 6.3 { + INSERT INTO main.t1 VALUES(1); +} {1 error} +db2 close + finish_test |
