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/session4.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 / session4.test` 150 lines ยท 11933 bytes Raw Blame History 1 # 2011 March 25 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 # This file implements regression tests for the session module. 12 # 13 14 if {$tcl_version<8.6} { 15 puts "This module requires Tcl 8.6 or later" 16 return 17 } 18 19 if {![info exists testdir]} { 20 set testdir [file join [file dirname [info script]] .. .. test] 21 } 22 source [file join [file dirname [info script]] session_common.tcl] 23 source $testdir/tester.tcl 24 ifcapable !session {finish_test; return} 25 26 set testprefix session4 27 28 do_test 1.0 { 29 execsql { 30 CREATE TABLE x(a, b, c, d, e, PRIMARY KEY(c, e)); 31 INSERT INTO x VALUES(65.21, X'28B0', 16.35, NULL, 'doers'); 32 INSERT INTO x VALUES(NULL, 78.49, 2, X'60', -66); 33 INSERT INTO x VALUES('cathedral', NULL, 35, NULL, X'B220937E80A2D8'); 34 INSERT INTO x VALUES(NULL, 'masking', -91.37, NULL, X'596D'); 35 INSERT INTO x VALUES(19, 'domains', 'espouse', -94, 'throw'); 36 } 37 38 set changeset [changeset_from_sql { 39 DELETE FROM x WHERE e = -66; 40 UPDATE x SET a = 'parameterizable', b = 31.8 WHERE c = 35; 41 INSERT INTO x VALUES(-75.61, -17, 16.85, NULL, X'D73DB02678'); 42 }] 43 set {} {} 44 } {} 45 46 47 # This currently causes crashes. sqlite3changeset_invert() does not handle 48 # corrupt changesets well. 49 if 0 { 50 do_test 1.1 { 51 for {set i 0} {$i < [string length $changeset]} {incr i} { 52 set before [string range $changeset 0 [expr $i-1]] 53 set after [string range $changeset [expr $i+1] end] 54 for {set j 10} {$j < 260} {incr j} { 55 set x [binary format "a*ca*" $before $j $after] 56 catch { sqlite3changeset_invert $x } 57 } 58 } 59 } {} 60 } 61 62 do_test 1.2 { 63 set x [binary format "ca*" 0 [string range $changeset 1 end]] 64 list [catch { sqlite3changeset_invert $x } msg] $msg 65 } {1 SQLITE_CORRUPT} 66 67 do_test 1.3 { 68 set x [binary format "ca*" 0 [string range $changeset 1 end]] 69 list [catch { sqlite3changeset_apply db $x xConflict } msg] $msg 70 } {1 SQLITE_CORRUPT} 71 72 #------------------------------------------------------------------------- 73 reset_db 74 do_execsql_test 2.0 { 75 CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d); 76 CREATE TABLE t2(e TEXT PRIMARY KEY NOT NULL,f,g); 77 CREATE TABLE t3(w REAL PRIMARY KEY NOT NULL,x,y); 78 CREATE TABLE t4(z PRIMARY KEY) WITHOUT ROWID; 79 } 80 81 foreach {tn blob} { 82 1 `54010174340012000000` 83 2 `54fefe8bcb0012000300` 84 3 `5480809280808001017434001200fb` 85 4 `50af9c939c9c9cb09c9c6400b09c9c6400` 86 5 `12000300` 87 6 `09847304` 88 7 `5401017434001208` 89 8 `54010174340012fc0386868600` 90 9 54010174340012FC0386868600 91 10 548894FEFE 92 11 54010171340012E703ABFA7433FD1200 93 12 540101743400120003FFED00010000000000000002120002400C00000000000054040100000074310017000100000000000000050100000000000000030100000000000000040000010000000000000004010000000000000003001700010000000000000007030378797A01000000000000000F000001000000000000000F030378797A005403010000743200090003037838790100000000800000000200000000000000000900030378327902400C0000000000000304666F7572 94 13 540101743400120003001200010000000000000002120002400C0000000000005404010000007431001700010000000000000005010000000000000003010000000000000004000001000000000000000401000000000000000300170001000000000000000703FC87797A01000000000000000F000001000000000000000F030378797A005403010000743200090003037838790100000000800000000200000000000000000900030378327902400C0000000000000304666F7572 95 14 540101743400120003001200010000000000000002120002400C00000000000054040100000074310017000100000000000000050100000000000000030100000000000000040000010000000000000004010000000000000003001700010000000000000007030378797A01000000000000000F000001000000000000000F03FC87797A005403010000743200090003037838790100000000800000000200000000000000000900030378327902400C0000000000000304666F7572 96 15 540101743400120003001200010000000000000002120002400C00000000000054040100000074310017000100000000000000050100000000000000030100000000000000040000010000000000000004010000000000000003001700010000000000000007030378797A01000000000000000F000001000000000000000F030378797A005403010000743200090003FC8738790100000000800000000200000000000000000900030378327902400C0000000000000304666F7572 97 16 540101743400120003001200010000000000000002120002400C00000000000054040100000074310017000100000000000000050100000000000000030100000000000000040000010000000000000004010000000000000003001700010000000000000007030378797A01000000000000000F000001000000000000000F030378797A00540301000074320009000303783879010000000080000000020000000000000000090003FC87327902400C0000000000000304666F7572 98 17 540101743400120003FFE3000412F7010000E600000000021202120002400C0000000000005B0401000000743100171C0304646F750002400C000000000000540401000000D3310017000100000000000000050100000000000378797A405403000002F10100000100000000000004090001000100000007030378797A0100000000000D0007000001000000002300000F1B0378797A405403013900743200090003038C3879010000000000000000000002120002400C0000000000005B0401000000743117170003047C5E00FF 99 18 54010174340012000300120001000000E6FF100000120002401E00000000000054040100000074310017000100040000010000000000000004FFFF7FFF0000000000010000010000001000000007030378797A01000000000000000F000000000000FA0304666F7572 100 19 540101743400120003001200010000000000000002121B02400C00000000000054040000000074310017000100000000000000050100000000000000030100000000000000040000010000000000000004010000000000000003001700010000000000000007030378817A01000000000000000F000001000000000100000F030378797A005403010000743200090003FFE809000303780000000000000304666F7572 101 20 5401017D3400120003001200010000000000000002120002400CFC00000000005404010000007431001700010000000000000005010000000000000003010000000000000004000001000000000000000401000000000000000300170001000000000000000703FFFF797A01000000000000000F000001000000000000000F030378797A005403010000743200090003037838790100000000800000000200000000000000000900030378326C02400C0000000000000304666F7572 102 21 5401017434001200030012000100FFE20000000002120002400C00000000000054040100E0007431001700010000E99D000000020000000003FFE70009000303783279020004000001030000000000002117000003001700012701000100000000743100000100000000008000090003037F387901000000008000000002000000000400000009005303010A00FF7FFFFF00000000000304664F6572 103 22 540101743400120003FFFF7FFF0000000000000002120002400C00000000000054040100000074310017000100000000000000050100000000000000030100010000000000000000040000010000000000000004010000000000000003001700010000000000000007030378797A01000000000000000F000001000000000000000F030378797A005403010000743200090003037838790100000000800000000200000000000000000900030378327902400C0000000000000304666F7572 104 23 540101742700120100120003F5FF0300 105 24 5401017434E312540101743400120003FFFC00 106 25 540101743400540101743D3D3D3D3D3D3D3D3D3D3D3D3D3400120003FFED000300 107 26 5401017446EA5301743D1D3D3D01743D1D3D3DCF3D3D3D1A3D3D3D3D3400120003FFFF000000 108 27 540101743400540101743D3D3D3D3D3D3D3D3D3D251000120003FF81000000000000 109 28 540101340012000397FF3D7F3D3400120003001200540101743D3D3D3D3D3D393D3D3D12000300 110 29 500174340050010F74340012000300120003FFE5 111 30 5004007233E900177FEF0054257F0002EF001200031E12000300 112 31 5001015001015252525250010174340012EF039A9A0100E351525D52525252525252525252525252525252525250010174340012EF039A0100009A9A9A9A9A9BA3B200120003010040743400 113 32 5401017400123400120003FFFC00 114 33 540101743400120003001200010000000000004002120002400C0000000000005404010000007431001700010000000000000005010000000000000003010000000000000004000001000000000000000401000000000000000300170001000000000000000703FC87797A01000000000000000F000001000000000000000F030378797A005403010000743200090003037838790100000000800000000200000000000000000900030378327902400C0000000000000304666F7572 115 34 54040100000074310017000100000002000015050100000000000000030100000000140000040000010000000000000004010000000000000003001700010000000000000007030378797A01000000000000000F000001000000000000000F030378797A0054030100007432000900030378387901000000008E000000020000000000000000090003FFFF000002400C0000000000000304666F7572 116 35 540101743400120003001200010000000000000002120002400C00000000000050060100000074310017000100000000000000050100000000000000030100000003001700010000666F7572 117 36 540101743400120003001200010000000000000002120002400C00000000000050050100000074310017000100000000000000050100000000000000030100000003001700010000666F7572 118 37 540101743400120003001200010000000000000002120002400C00000000000050040100008074310017000100000000000000050100000000000000030100000003001700010000666F7572 119 38 540101743400120003001200010000000000000002120002400C00000000000050040100000074310017000000000000000000050100000000000000030100000003001700010000666F7572 120 39 540101743400120003001200010000000000000002120002400C00000000000050040100018074310017000100000000000000050100000000000000030100000003001700010000666F7572 121 40 540101743400120003001200010000000000000002120002400C0000000000005004FEFFFFFF74310017000100000000000000050100000000000000030100000003001700010000666F7572 122 41 540101743400120003001200010000000000000002120002400C00000000000050040100000074310017000004000000000000050100000000000000030100000003001700010000666F7572 123 42 540101743400120003001200010000000000000002120002400C0000000000005005FFFF050074310017000100000000000000050100000000000000030100000003001700010000666F7572 124 43 540101743400120003001200010000000000000002120002400C000000000000500401006E0074310017000300000000001221050100000000000000030100000003001700010000666F7572 125 44 540101743400120003001200010000000000020000120002400C00000000000050050100000074310017000100000000000000050100004000000000030100000025001700010000666F7572 126 45 540101743400120003001200010000000000ECFF02120002400C000000000000500401F9FF00743100170001000000000000000500E1000000000000030100000003000000000000666F7572 127 46 54010174340B0B0B0B0B0B0B0B0B0B0B0B0B0B0B00120003001200010000000000000002120002400C00000000000050040100000074310017010000000000000000050100FFE900000000030100000003007F00000000666F7572 128 47 54010103001200010000000000020002120002400C0000000000005004010000F374310017000100000000000000050100000000000000030100000003001700010000666F8E72 129 48 540101743400120003001200010000000000000002120002400C00000000000050030012000174310017000700000000000000050100002000000001000000000003001700010000666F7572 130 49 540101743400120004001200010000000000000002120002400C0000000000005004010000FC733100170001000000000000000501000000000000000301000000F6FF17000100007C6F7572 131 50 54010174FFDDFF8003001200010000100000000002120002400C000000000000500401000000743100170000000005010000000000000000000003010072 132 51 540101743200120003001200010000000000000002120002400C00000000000050040100001074310017000000000003010000120300170100000000000000050100000000000000030100000003001700010000666F7572 133 52 540101745401017434001200010000000000001702120002400C00000000000050040100001A74310017000100000000000100000100000000000000030100000003001700010000666F7572 134 53 540101743400120003001200010000000000000002120002400C000000000000500401000000743100170001000002400C00000000000050040110000074310017000000000000050100000000000000030100000003001700010000666F7572 135 54 540101743400120003001200010000000000000002120002400C000000000002120002400C00000000000050040100000074310017FF0050040100000074310017FF7F00000000000000050100000000000000030100000003001700010000666F7572 136 55 540101743400120003001200010000000000000002120002400C00000000000050040100000074310017000100010080000001000000020003010100000300170100000003001700010000666F7572 137 56 `5487ffffff7f` 138 57 `54015052494e5446110017120004` 139 } { 140 do_test 2.$tn { 141 set changeset [binary decode hex $blob] 142 #set fd [open x.change w+] 143 #fconfigure $fd -translation binary 144 #puts -nonewline $fd $changeset 145 #close $fd 146 list [catch { sqlite3changeset_apply db $changeset xConflict } msg] $msg 147 } {1 SQLITE_CORRUPT} 148 } 149 150 finish_test