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 / changesetfuzz1.test

83 lines · 2204 bytes Raw Blame History
1# 2018 November 08
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
13if {![info exists testdir]} {
14 set testdir [file join [file dirname [info script]] .. .. test]
15}
16source [file join [file dirname [info script]] session_common.tcl]
17source $testdir/tester.tcl
18ifcapable !session {finish_test; return}
19set testprefix changesetfuzz1
20
21
22set CF [test_find_binary changesetfuzz]
23if {$CF==""} {
24 finish_test
25 return
26}
27
28proc writefile {zFile data} {
29 set fd [open $zFile w]
30 fconfigure $fd -translation binary
31 puts -nonewline $fd $data
32 close $fd
33}
34
35do_execsql_test 1.0 {
36 CREATE TABLE t1(a, b, c, d, PRIMARY KEY(c, d));
37 CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
38
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);
43}
44
45set 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';
50}]
51writefile c1.changeset $C
52
53do_test 1.1 {
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
60 }
61 }
62} {}
63
64set 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';
69}]
70writefile p1.patchset $P
71do_test 1.2 {
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
78 }
79 }
80} {}
81
82
83finish_test