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 #***********************************************************************
13 if {![info exists testdir]} {
14 set testdir [file join [file dirname [info script]] .. .. test]
16 source [file join [file dirname [info script]] session_common.tcl]
17 source $testdir/tester.tcl
18 ifcapable !session {finish_test; return}
19 set testprefix changesetfuzz1
22 set CF [test_find_binary changesetfuzz]
28 proc writefile {zFile data} {
29 set fd [open $zFile w]
30 fconfigure $fd -translation binary -encoding binary
31 puts -nonewline $fd $data
36 CREATE TABLE t1(a, b, c, d, PRIMARY KEY(c, d));
37 CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
39 INSERT INTO t1 VALUES ('one', 'two', 'three', 'four'),
40 ('five', 'six', 'seven', 'eight'),
41 ('nine', 'ten', 'eleven', 'twelve');
42 INSERT INTO t2 VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
45 set C [changeset_from_sql {
46 INSERT INTO t2 VALUES(10, 11, 12);
47 DELETE FROM t2 WHERE a=1;
48 UPDATE t1 SET b='forty-five' WHERE a='one';
49 UPDATE t1 SET a='twenty-nine', b='seventy' WHERE a='five';
51 writefile c1.changeset $C
54 for {set j 0} {$j < 200} {incr j} {
55 forcecopy c1.changeset input.changeset
56 for {set i 0} {$i < 6} {incr i} {
57 exec $CF input.changeset $i 1
58 exec $CF input.changeset-0
59 forcecopy input.changeset-0 input.changeset
64 set P [patchset_from_sql {
65 INSERT INTO t2 VALUES(13, 14, 15);
66 DELETE FROM t2 WHERE a=4;
67 UPDATE t1 SET b='thirteen' WHERE a='one';
68 UPDATE t1 SET a='ninety-seven', b='twenty' WHERE a='five';
70 writefile p1.patchset $P
72 for {set j 0} {$j < 200} {incr j} {
73 forcecopy p1.patchset input.patchset
74 for {set i 0} {$i < 6} {incr i} {
75 exec $CF input.patchset $i 1
76 exec $CF input.patchset-0
77 forcecopy input.patchset-0 input.patchset