3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for the session module.
14 if {![info exists testdir]} {
15 set testdir [file join [file dirname [info script]] .. .. test]
17 source [file join [file dirname [info script]] session_common.tcl]
18 source $testdir/tester.tcl
19 ifcapable !session {finish_test; return}
21 set testprefix session4
25 CREATE TABLE x(a, b, c, d, e, PRIMARY KEY(c, e));
26 INSERT INTO x VALUES(65.21, X'28B0', 16.35, NULL, 'doers');
27 INSERT INTO x VALUES(NULL, 78.49, 2, X'60', -66);
28 INSERT INTO x VALUES('cathedral', NULL, 35, NULL, X'B220937E80A2D8');
29 INSERT INTO x VALUES(NULL, 'masking', -91.37, NULL, X'596D');
30 INSERT INTO x VALUES(19, 'domains', 'espouse', -94, 'throw');
33 set changeset [changeset_from_sql {
34 DELETE FROM x WHERE e = -66;
35 UPDATE x SET a = 'parameterizable', b = 31.8 WHERE c = 35;
36 INSERT INTO x VALUES(-75.61, -17, 16.85, NULL, X'D73DB02678');
42 # This currently causes crashes. sqlite3changeset_invert() does not handle
43 # corrupt changesets well.
46 for {set i 0} {$i < [string length $changeset]} {incr i} {
47 set before [string range $changeset 0 [expr $i-1]]
48 set after [string range $changeset [expr $i+1] end]
49 for {set j 10} {$j < 260} {incr j} {
50 set x [binary format "a*ca*" $before $j $after]
51 catch { sqlite3changeset_invert $x }
58 set x [binary format "ca*" 0 [string range $changeset 1 end]]
59 list [catch { sqlite3changeset_invert $x } msg] $msg
63 set x [binary format "ca*" 0 [string range $changeset 1 end]]
64 list [catch { sqlite3changeset_apply db $x xConflict } msg] $msg