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

Side by Side Diff: third_party/sqlite/src/ext/session/sessionA.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
OLDNEW
(Empty)
1 # 2013 July 04
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 # This file tests that filter callbacks work as required.
13 #
14
15 if {![info exists testdir]} {
16 set testdir [file join [file dirname [info script]] .. .. test]
17 }
18 source [file join [file dirname [info script]] session_common.tcl]
19 source $testdir/tester.tcl
20 ifcapable !session {finish_test; return}
21 set testprefix sessionA
22
23
24 forcedelete test.db2
25 sqlite3 db2 test.db2
26 foreach {tn db} {1 db 2 db2} {
27 do_test 1.$tn.1 {
28 execsql {
29 CREATE TABLE t1(a PRIMARY KEY, b);
30 CREATE TABLE t2(a PRIMARY KEY, b);
31 CREATE TABLE t3(a PRIMARY KEY, b);
32 } $db
33 } {}
34 }
35
36 proc tbl_filter {zTbl} {
37 return $::table_filter($zTbl)
38 }
39
40 do_test 2.1 {
41 set ::table_filter(t1) 1
42 set ::table_filter(t2) 0
43 set ::table_filter(t3) 1
44
45 sqlite3session S db main
46 S table_filter tbl_filter
47
48 execsql {
49 INSERT INTO t1 VALUES('a', 'b');
50 INSERT INTO t2 VALUES('c', 'd');
51 INSERT INTO t3 VALUES('e', 'f');
52 }
53
54 set changeset [S changeset]
55 S delete
56 sqlite3changeset_apply db2 $changeset xConflict
57
58 execsql {
59 SELECT * FROM t1;
60 SELECT * FROM t2;
61 SELECT * FROM t3;
62 } db2
63 } {a b e f}
64
65 #-------------------------------------------------------------------------
66 # Test that filter callbacks passed to sqlite3changeset_apply() are
67 # invoked correctly.
68 #
69 reset_db
70 do_execsql_test 3.1 {
71 CREATE TABLE t1(a PRIMARY KEY, b);
72 CREATE TABLE t2(x PRIMARY KEY, y);
73 }
74
75 do_test 3.2 {
76 execsql BEGIN
77 set ::cs [changeset_from_sql {
78 INSERT INTO t1 VALUES(1, 2);
79 INSERT INTO t2 VALUES('x', 'y');
80 }]
81 execsql ROLLBACK
82 set {} {}
83 } {}
84
85 proc filter {x y} {
86 return [string equal $x $y]
87 }
88
89 do_test 3.3 {
90 sqlite3changeset_apply db $::cs {} [list filter t1]
91 execsql {
92 SELECT * FROM t1;
93 SELECT * FROM t2;
94 }
95 } {1 2}
96
97 do_test 3.4 {
98 execsql { DELETE FROM t1 }
99 sqlite3changeset_apply db $::cs {} [list filter t2]
100 execsql {
101 SELECT * FROM t1;
102 SELECT * FROM t2;
103 }
104 } {x y}
105
106 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/session/session9.test ('k') | third_party/sqlite/src/ext/session/sessionB.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698