interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / session / sessionI.test

88 lines · 1807 bytes Raw Blame History
1# 2015 July 14
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#
13
14if {![info exists testdir]} {
15 set testdir [file join [file dirname [info script]] .. .. test]
16}
17source [file join [file dirname [info script]] session_common.tcl]
18source $testdir/tester.tcl
19ifcapable !session {finish_test; return}
20
21set testprefix sessionI
22
23forcedelete test.db2
24sqlite3 db2 test.db2
25
26do_test 1.0 {
27 do_common_sql {
28 CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
29 }
30} {}
31
32set C [changeset_from_sql {
33 INSERT INTO t1 VALUES(1, 'one');
34 INSERT INTO t1 VALUES(2, 'two');
35 INSERT INTO t1 VALUES(3, 'three');
36 INSERT INTO t1 VALUES(4, 'four');
37 INSERT INTO t1 VALUES(5, 'five');
38 INSERT INTO t1 VALUES(6, 'six');
39}]
40
41do_execsql_test 1.1 {
42 SELECT * FROM t1
43} {
44 1 one 2 two 3 three 4 four 5 five 6 six
45}
46
47proc xFilter {data} {
48 foreach {op tname flag pk old new} $data {}
49 if {$op=="INSERT"} {
50 set ipk [lindex $new 1]
51 return [expr $ipk % 2]
52 }
53 return 1
54}
55proc xConflict {args} {
56}
57
58sqlite3changeset_apply_v3 db2 $C xConflict xFilter
59
60do_execsql_test -db db2 1.2 {
61 SELECT * FROM t1
62} {
63 1 one 3 three 5 five
64}
65
66do_execsql_test -db db2 1.3 {
67 DELETE FROM t1
68}
69sqlite3changeset_apply_v3 db2 $C xConflict
70
71do_execsql_test -db db2 1.4 {
72 SELECT * FROM t1
73} {
74 1 one 2 two 3 three 4 four 5 five 6 six
75}
76
77proc xFilter2 {data} {
78 return 0
79}
80do_execsql_test -db db2 1.5 {
81 DELETE FROM t1
82}
83sqlite3changeset_apply_v3 db2 $C xConflict xFilter2
84do_execsql_test -db db2 1.6 {
85 SELECT * FROM t1
86} { }
87
88finish_test