summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/src/test/savepoint3.test
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 23:37:03 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 23:37:03 +0000
commite33cba46498a40774bc6d33a9258afbd5fa059e6 (patch)
tree4ce6b22f4f7b2b245b2d89bb9209a53e3274b263 /third_party/sqlite/src/test/savepoint3.test
parentaaf6472fd01db928919d4dc13687bde2a4b5c7b9 (diff)
downloadchromium_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/savepoint3.test')
-rw-r--r--third_party/sqlite/src/test/savepoint3.test136
1 files changed, 136 insertions, 0 deletions
diff --git a/third_party/sqlite/src/test/savepoint3.test b/third_party/sqlite/src/test/savepoint3.test
new file mode 100644
index 0000000..0dcb0ac
--- /dev/null
+++ b/third_party/sqlite/src/test/savepoint3.test
@@ -0,0 +1,136 @@
+# 2008 December 15
+#
+# 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.
+#
+#***********************************************************************
+#
+# $Id: savepoint3.test,v 1.5 2009/06/05 17:09:12 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+source $testdir/malloc_common.tcl
+
+do_malloc_test savepoint3-1 -sqlprep {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+} -sqlbody {
+ SAVEPOINT one;
+ INSERT INTO t1 VALUES(4, 5, 6);
+ SAVEPOINT two;
+ DELETE FROM t1;
+ ROLLBACK TO two;
+ RELEASE one;
+}
+
+do_malloc_test savepoint3-2 -sqlprep {
+ PRAGMA cache_size = 10;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400));
+ INSERT INTO t1 SELECT
+ randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+ INSERT INTO t1
+ SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
+} -sqlbody {
+ PRAGMA cache_size = 10;
+ SAVEPOINT one;
+ DELETE FROM t1 WHERE rowid < 5;
+ SAVEPOINT two;
+ DELETE FROM t1 WHERE rowid > 10;
+ ROLLBACK TO two;
+ ROLLBACK TO one;
+ RELEASE one;
+}
+
+do_ioerr_test savepoint3.3 -sqlprep {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000));
+} -sqlbody {
+ BEGIN;
+ UPDATE t1 SET a = 3 WHERE a = 1;
+ SAVEPOINT one;
+ UPDATE t1 SET a = 4 WHERE a = 2;
+ COMMIT;
+} -cleanup {
+ db eval {
+ SAVEPOINT one;
+ RELEASE one;
+ }
+}
+
+# The following test does a really big savepoint rollback. One involving
+# more than 4000 pages. The idea is to get a specific sqlite3BitvecSet()
+# operation in pagerPlaybackSavepoint() to fail.
+#do_malloc_test savepoint3-4 -sqlprep {
+# BEGIN;
+# CREATE TABLE t1(a, b);
+# CREATE INDEX i1 ON t1(a);
+# CREATE INDEX i2 ON t1(b);
+# INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 1
+# INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 2
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 4
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 8
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 16
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 32
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 64
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 128
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 256
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 512
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 1024
+# INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048
+# COMMIT;
+# BEGIN;
+# SAVEPOINT abc;
+# UPDATE t1 SET a = randstr(500,500);
+#} -sqlbody {
+# ROLLBACK TO abc;
+#}
+
+
+# Cause a specific malloc in savepoint rollback code to fail.
+#
+do_malloc_test savepoint3-4 -start 7 -sqlprep {
+ PRAGMA auto_vacuum = incremental;
+ PRAGMA cache_size = 1000;
+
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE TABLE t3(a, b);
+ INSERT INTO t1 VALUES(1, randstr(500,500));
+ INSERT INTO t1 VALUES(2, randstr(500,500));
+ INSERT INTO t1 VALUES(3, randstr(500,500));
+ DELETE FROM t1;
+
+ BEGIN;
+ INSERT INTO t1 VALUES(1, randstr(500,500));
+ INSERT INTO t1 VALUES(2, randstr(500,500));
+ INSERT INTO t1 VALUES(3, randstr(500,500));
+ DROP TABLE t3; -- Page 5 of the database file is now free.
+ DROP TABLE t2; -- Page 4 of the database file is now free.
+
+ SAVEPOINT abc;
+ PRAGMA incremental_vacuum;
+} -sqlbody {
+ ROLLBACK TO abc;
+}
+
+
+finish_test