Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/session/sessionI.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 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 sessionI 22 23 forcedelete test.db2 24 sqlite3 db2 test.db2 25 26 do_test 1.0 { 27 do_common_sql { 28 CREATE TABLE t1(x INTEGER PRIMARY KEY, y); 29 } 30 } {} 31 32 set 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 41 do_execsql_test 1.1 { 42 SELECT * FROM t1 43 } { 44 1 one 2 two 3 three 4 four 5 five 6 six 45 } 46 47 proc 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 } 55 proc xConflict {args} { 56 } 57 58 sqlite3changeset_apply_v3 db2 $C xConflict xFilter 59 60 do_execsql_test -db db2 1.2 { 61 SELECT * FROM t1 62 } { 63 1 one 3 three 5 five 64 } 65 66 do_execsql_test -db db2 1.3 { 67 DELETE FROM t1 68 } 69 sqlite3changeset_apply_v3 db2 $C xConflict 70 71 do_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 77 proc xFilter2 {data} { 78 return 0 79 } 80 do_execsql_test -db db2 1.5 { 81 DELETE FROM t1 82 } 83 sqlite3changeset_apply_v3 db2 $C xConflict xFilter2 84 do_execsql_test -db db2 1.6 { 85 SELECT * FROM t1 86 } { } 87 88 finish_test