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

Side by Side Diff: third_party/sqlite/sqlite-src-3170000/ext/session/session8.test

Issue 2747283002: [sql] Import reference version of SQLite 3.17.. (Closed)
Patch Set: 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
OLDNEW
(Empty)
1 # 2011 July 13
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 # This file implements regression tests for SQLite library.
12 #
13
14 if {![info exists testdir]} {
15 set testdir [file join [file dirname [info script]] .. .. test]
16 }
17 source [file join [file dirname [info script]] session_common.tcl]
18 source $testdir/tester.tcl
19 ifcapable !session {finish_test; return}
20
21 set testprefix session8
22
23 proc noop {args} {}
24
25 # Like [dbcksum] in tester.tcl. Except this version is not sensitive
26 # to changes in the value of implicit IPK columns.
27 #
28 proc udbcksum {db dbname} {
29 if {$dbname=="temp"} {
30 set master sqlite_temp_master
31 } else {
32 set master $dbname.sqlite_master
33 }
34 set alltab [$db eval "SELECT name FROM $master WHERE type='table'"]
35 set txt [$db eval "SELECT * FROM $master"]\n
36 foreach tab $alltab {
37 append txt [lsort [$db eval "SELECT * FROM $dbname.$tab"]]\n
38 }
39 return [md5 $txt]
40 }
41
42 proc do_then_undo {tn sql} {
43 set ck1 [udbcksum db main]
44
45 sqlite3session S db main
46 S attach *
47 db eval $sql
48
49 set ck2 [udbcksum db main]
50
51 set invert [sqlite3changeset_invert [S changeset]]
52 S delete
53 sqlite3changeset_apply db $invert noop
54
55 set ck3 [udbcksum db main]
56
57 set a [expr {$ck1==$ck2}]
58 set b [expr {$ck1==$ck3}]
59 uplevel [list do_test $tn.1 "set {} $a" 0]
60 uplevel [list do_test $tn.2 "set {} $b" 1]
61 }
62
63 do_execsql_test 1.1 {
64 CREATE TABLE t1(a PRIMARY KEY, b);
65 INSERT INTO t1 VALUES(1, 2);
66 INSERT INTO t1 VALUES("abc", "xyz");
67 }
68 do_then_undo 1.2 { INSERT INTO t1 VALUES(3, 4); }
69 do_then_undo 1.3 { DELETE FROM t1 WHERE b=2; }
70 do_then_undo 1.4 { UPDATE t1 SET b = 3 WHERE a = 1; }
71
72 do_execsql_test 2.1 {
73 CREATE TABLE t2(a, b PRIMARY KEY);
74 INSERT INTO t2 VALUES(1, 2);
75 INSERT INTO t2 VALUES('abc', 'xyz');
76 }
77 do_then_undo 1.2 { INSERT INTO t2 VALUES(3, 4); }
78 do_then_undo 1.3 { DELETE FROM t2 WHERE b=2; }
79 do_then_undo 1.4 { UPDATE t1 SET a = '123' WHERE b = 'xyz'; }
80
81 do_execsql_test 3.1 {
82 CREATE TABLE t3(a, b, c, d, e, PRIMARY KEY(c, e));
83 INSERT INTO t3 VALUES('x', 45, 0.0, 'abcdef', 12);
84 INSERT INTO t3 VALUES(45, 0.0, 'abcdef', 12, 'x');
85 INSERT INTO t3 VALUES(0.0, 'abcdef', 12, 'x', 45);
86 }
87
88 do_then_undo 3.2 { UPDATE t3 SET b=b||b WHERE e!='x' }
89 do_then_undo 3.3 { UPDATE t3 SET a = 46 }
90
91 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698