diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 23:37:03 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 23:37:03 +0000 |
commit | e33cba46498a40774bc6d33a9258afbd5fa059e6 (patch) | |
tree | 4ce6b22f4f7b2b245b2d89bb9209a53e3274b263 /third_party/sqlite/src/test/tkt2820.test | |
parent | aaf6472fd01db928919d4dc13687bde2a4b5c7b9 (diff) | |
download | chromium_src-e33cba46498a40774bc6d33a9258afbd5fa059e6.zip chromium_src-e33cba46498a40774bc6d33a9258afbd5fa059e6.tar.gz chromium_src-e33cba46498a40774bc6d33a9258afbd5fa059e6.tar.bz2 |
Move bundled copy of sqlite one level deeper to better separate it
from our patches, READMEs, etc.
Also, add a shim header so we can use it for building
with system sqlite.
TEST=compile
BUG=22208
Review URL: http://codereview.chromium.org/3108030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/sqlite/src/test/tkt2820.test')
-rw-r--r-- | third_party/sqlite/src/test/tkt2820.test | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/third_party/sqlite/src/test/tkt2820.test b/third_party/sqlite/src/test/tkt2820.test new file mode 100644 index 0000000..106c1e5 --- /dev/null +++ b/third_party/sqlite/src/test/tkt2820.test @@ -0,0 +1,94 @@ +# 2007 Dec 4 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# This file is to test that ticket #2820 has been fixed. +# Ticket #2820 observes that a DROP TABLE statement that +# occurs while a query is in process will fail with a +# "database is locked" error, but the entry in the sqlite_master +# table will still be removed. This is incorrect. The +# entry in the sqlite_master table should persist when +# the DROP fails due to an error. +# +# $Id: tkt2820.test,v 1.1 2007/12/04 16:54:53 drh Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +proc test_schema_change {testid init ddl res} { + db close + file delete -force test.db test.db-journal + sqlite3 db test.db + execsql $init + do_test tkt2820-$testid.1 { + set STMT [sqlite3_prepare db {SELECT * FROM sqlite_master} -1 DUMMY] + sqlite3_step $STMT + } {SQLITE_ROW} +#if {$testid==3} {execsql {PRAGMA vdbe_trace=ON}} + do_test tkt2820-$testid.2 "catchsql [list $ddl]" \ + {1 {database table is locked}} + do_test tkt2820-$testid.3 { + sqlite3_finalize $STMT + execsql {SELECT name FROM sqlite_master ORDER BY 1} + } $res + integrity_check tkt2820-$testid.4 + db close + sqlite3 db test.db + integrity_check tkt2820-$testid.5 +} + +test_schema_change 1 { + CREATE TABLE t1(a); +} { + DROP TABLE t1 +} {t1} +test_schema_change 2 { + CREATE TABLE t1(a); + CREATE TABLE t2(b); +} { + DROP TABLE t2 +} {t1 t2} +test_schema_change 3 { + CREATE TABLE t1(a); + CREATE INDEX i1 ON t1(a); +} { + DROP INDEX i1 +} {i1 t1} + +# We further observe that prior to the fix associated with ticket #2820, +# no statement journal would be created on an SQL statement that was run +# while a second statement was active, as long as we are in autocommit +# mode. This is incorrect. +# +do_test tkt2820-4.1 { + db close + file delete -force test.db test.db-journal + sqlite3 db test.db + db eval { + CREATE TABLE t1(a INTEGER PRIMARY KEY); + INSERT INTO t1 VALUES(1); + INSERT INTO t1 VALUES(2); + } + + # The INSERT statement within the loop should fail on a + # constraint violation on the second inserted row. This + # should cause the entire INSERT to rollback using a statement + # journal. + # + db eval {SELECT name FROM sqlite_master} { + catch {db eval { + INSERT INTO t1 SELECT a+1 FROM t1 ORDER BY a DESC + }} + } + db eval {SELECT a FROM t1 ORDER BY a} +} {1 2} + +finish_test |