Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: third_party/sqlite/src/test/tempdb2.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/tempdb.test ('k') | third_party/sqlite/src/test/tempfault.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2016 March 3
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
9 #
10 #***********************************************************************
11
12 set testdir [file dirname $argv0]
13 source $testdir/tester.tcl
14 set testprefix tempdb2
15
16 db close
17 sqlite3 db ""
18
19 proc int2str {i} { string range [string repeat "$i." 450] 0 899 }
20 db func int2str int2str
21
22 #-------------------------------------------------------------------------
23 #
24 # 1.1: Write a big transaction to the db. One so large that it forces
25 # the file to be created and the cache flushed to disk on COMMIT.
26 #
27 # 1.2: Write a small transaction - one small enough that it remains in
28 # memory on COMMIT. All the pages of table [t1] are now dirty.
29 #
30 # 1.3: Delete the contents of [t1]. This moves all of its leaves to the
31 # free-list and causes the btree layer to call PagerDontWrite() on
32 # each of them.
33 #
34 # Then do a big update on table [t2]. So big that the former leaves
35 # of [t1] are forced out of the cache. Then roll back the transaction.
36 # If the PagerDontWrite() calls are honoured and the data is not written
37 # to disk, the update made in test 1.2 will be lost at this point. Or, if
38 # they are ignored (as they should be for temp databases), the update
39 # will be safely written out to disk before the cache entries are
40 # discarded.
41 #
42 do_execsql_test 1.1 {
43 PRAGMA page_size=1024;
44 PRAGMA cache_size=50;
45
46 BEGIN;
47 CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
48 INSERT INTO t1 VALUES(1, int2str(1));
49 INSERT INTO t1 VALUES(2, int2str(1));
50 INSERT INTO t1 VALUES(3, int2str(1));
51
52 CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
53 WITH c(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100 )
54 INSERT INTO t2 SELECT x, int2str(x) FROM c;
55 COMMIT;
56
57 PRAGMA lock_status;
58 } {main unlocked temp closed}
59
60 do_execsql_test 1.2 {
61 UPDATE t1 SET b=int2str(2);
62 SELECT b=int2str(2) FROM t1
63 } {1 1 1}
64
65 do_execsql_test 1.3 {
66 BEGIN;
67 DELETE FROM t1;
68 UPDATE t2 SET b=int2str(a+1);
69 ROLLBACK;
70 }
71
72 do_execsql_test 1.4 {
73 SELECT b=int2str(2) FROM t1
74 } {1 1 1}
75
76 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/tempdb.test ('k') | third_party/sqlite/src/test/tempfault.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698