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/session_gen.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 / session_gen.test` 191 lines ยท 3890 bytes Raw Blame History 1 # 2025 Jan 28 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 SQLite library. 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 session_gen 22 23 24 foreach {otn sct} { 25 1 VIRTUAL 26 2 STORED 27 } { 28 eval [string map [list %TYPE% $sct] { 29 reset_db 30 set testprefix $testprefix-$otn 31 32 do_execsql_test 1.0 { 33 CREATE TABLE t1(a INTEGER PRIMARY KEY, b); 34 35 CREATE TABLE t2(a INTEGER PRIMARY KEY, b AS (c+1) %TYPE%, c); 36 37 CREATE TABLE t3( 38 a, 39 b AS (a+10) %TYPE%, 40 c, 41 d AS (c+1) %TYPE%, 42 e, 43 PRIMARY KEY(c, e) 44 ) WITHOUT ROWID; 45 46 CREATE TABLE t4(a AS (c*100) %TYPE%, b INTEGER PRIMARY KEY, c); 47 48 CREATE TABLE t5(x, y); 49 } 50 51 foreach {tn sql changeset} { 52 53 0.1 { 54 INSERT INTO t5 VALUES('abc', 'def'); 55 } { 56 {INSERT t5 0 X.. {} {i 1 t abc t def}} 57 } 58 0.2 { 59 UPDATE t5 SET y='xyz' WHERE rowid=1; 60 } { 61 {UPDATE t5 0 X.. {i 1 {} {} t def} {{} {} {} {} t xyz}} 62 } 63 0.3 { 64 DELETE FROM t5; 65 } { 66 {DELETE t5 0 X.. {i 1 t abc t xyz} {}} 67 } 68 69 1.1 { 70 INSERT INTO t2 VALUES(1, 2); 71 INSERT INTO t2 VALUES(2, 123); 72 } { 73 {INSERT t2 0 X. {} {i 1 i 2}} 74 {INSERT t2 0 X. {} {i 2 i 123}} 75 } 76 1.2 { 77 UPDATE t2 SET c=456 WHERE a=1 78 } { 79 {UPDATE t2 0 X. {i 1 i 2} {{} {} i 456}} 80 } 81 82 1.3 { 83 DELETE FROM t2 WHERE a=2 84 } { 85 {DELETE t2 0 X. {i 2 i 123} {}} 86 } 87 88 1.4 { 89 UPDATE t2 SET a=15 90 } { 91 {INSERT t2 0 X. {} {i 15 i 456}} 92 {DELETE t2 0 X. {i 1 i 456} {}} 93 } 94 95 2.1 { 96 INSERT INTO t3 VALUES(5, 6, 7); 97 INSERT INTO t3 VALUES(8, 9, 10); 98 } { 99 {INSERT t3 0 .XX {} {i 8 i 9 i 10}} 100 {INSERT t3 0 .XX {} {i 5 i 6 i 7}} 101 } 102 103 2.2 { 104 UPDATE t3 SET a = 505 WHERE (c, e) = (6, 7); 105 } { 106 {UPDATE t3 0 .XX {i 5 i 6 i 7} {i 505 {} {} {} {}}} 107 } 108 109 2.3 { 110 DELETE FROM t3 WHERE (c, e) = (9, 10); 111 } { 112 {DELETE t3 0 .XX {i 8 i 9 i 10} {}} 113 } 114 115 2.4 { 116 UPDATE t3 SET c=1000 117 } { 118 {DELETE t3 0 .XX {i 505 i 6 i 7} {}} 119 {INSERT t3 0 .XX {} {i 505 i 1000 i 7}} 120 } 121 122 3.1 { 123 INSERT INTO t4 VALUES(100, 100); 124 } { 125 {INSERT t4 0 X. {} {i 100 i 100}} 126 } 127 128 } { 129 do_test 1.$tn.1 { 130 sqlite3session S db main 131 S object_config rowid 1 132 S attach * 133 execsql $sql 134 } {} 135 136 do_changeset_test 1.$tn.2 S $changeset 137 138 S delete 139 } 140 #------------------------------------------------------------------------- 141 reset_db 142 143 forcedelete test.db2 144 sqlite3 db2 test.db2 145 146 do_common_sql { 147 CREATE TABLE t0(x INTEGER PRIMARY KEY, y); 148 INSERT INTO t0 VALUES(1, 'one'); 149 INSERT INTO t0 VALUES(2, 'two'); 150 151 CREATE TABLE t1(a AS (c*10) %TYPE%, b INTEGER PRIMARY KEY, c); 152 INSERT INTO t1 VALUES(1, 5); 153 INSERT INTO t1 VALUES(2, 10); 154 INSERT INTO t1 VALUES(3, 5); 155 156 CREATE TABLE t2( 157 a, b, c AS (a*b) %TYPE%, 158 'k 1', 'k 2', PRIMARY KEY('k 1', 'k 2') 159 ) WITHOUT ROWID; 160 INSERT INTO t2 VALUES('a', 'b', 1, 11); 161 INSERT INTO t2 VALUES('A', 'B', 2, 22); 162 INSERT INTO t2 VALUES('Aa', 'Bb', 3, 33); 163 } 164 165 foreach {tn sql} { 166 1.1 { INSERT INTO t0 VALUES(4, 15) } 167 1.2 { INSERT INTO t1 VALUES(4, 15) } 168 1.3 { INSERT INTO t2 VALUES(1, 2, 3, 4) } 169 170 2.1 { UPDATE t1 SET c=100 WHERE b=2 } 171 2.2 { UPDATE t2 SET a=11 } 172 173 3.1 { DELETE FROM t2 WHERE (t2.'k 1') = 2 } 174 3.2 { DELETE FROM t1 } 175 } { 176 do_test 2.$tn.1 { 177 # execsql { PRAGMA vdbe_listing = 1 } db2 178 do_then_apply_sql $sql 179 } {} 180 do_test 2.$tn.2 { 181 compare_db db db2 182 } {} 183 } 184 db2 close 185 186 }]} 187 188 189 190 191 finish_test