github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/vfs/tests/mptest/testdata/crash01.test (about) 1 /* Test cases involving incomplete transactions that must be rolled back. 2 */ 3 --task 1 4 DROP TABLE IF EXISTS t1; 5 CREATE TABLE t1(a INTEGER PRIMARY KEY, b); 6 --sleep 1 7 INSERT INTO t1 VALUES(1, randomblob(2000)); 8 INSERT INTO t1 VALUES(2, randomblob(1000)); 9 --sleep 1 10 INSERT INTO t1 SELECT a+2, randomblob(1500) FROM t1; 11 INSERT INTO t1 SELECT a+4, randomblob(1500) FROM t1; 12 INSERT INTO t1 SELECT a+8, randomblob(1500) FROM t1; 13 --sleep 1 14 INSERT INTO t1 SELECT a+16, randomblob(1500) FROM t1; 15 --sleep 1 16 INSERT INTO t1 SELECT a+32, randomblob(1500) FROM t1; 17 SELECT count(*) FROM t1; 18 --match 64 19 SELECT avg(length(b)) FROM t1; 20 --match 1500.0 21 --sleep 2 22 UPDATE t1 SET b='x'||a||'y'; 23 SELECT sum(length(b)) FROM t1; 24 --match 247 25 SELECT a FROM t1 WHERE b='x17y'; 26 --match 17 27 CREATE INDEX t1b ON t1(b); 28 SELECT a FROM t1 WHERE b='x17y'; 29 --match 17 30 SELECT a FROM t1 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; 31 --match 29 28 27 26 25 32 --end 33 --wait 1 34 --task 2 35 DROP TABLE IF EXISTS t2; 36 CREATE TABLE t2(a INTEGER PRIMARY KEY, b); 37 INSERT INTO t2 SELECT a, b FROM t1; 38 UPDATE t1 SET b='x'||a||'y'; 39 SELECT sum(length(b)) FROM t2; 40 --match 247 41 SELECT a FROM t2 WHERE b='x17y'; 42 --match 17 43 CREATE INDEX t2b ON t2(b); 44 SELECT a FROM t2 WHERE b='x17y'; 45 --match 17 46 SELECT a FROM t2 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; 47 --match 29 28 27 26 25 48 --end 49 --task 3 50 DROP TABLE IF EXISTS t3; 51 CREATE TABLE t3(a INTEGER PRIMARY KEY, b); 52 INSERT INTO t3 SELECT a, b FROM t1; 53 UPDATE t1 SET b='x'||a||'y'; 54 SELECT sum(length(b)) FROM t3; 55 --match 247 56 SELECT a FROM t3 WHERE b='x17y'; 57 --match 17 58 CREATE INDEX t3b ON t3(b); 59 SELECT a FROM t3 WHERE b='x17y'; 60 --match 17 61 SELECT a FROM t3 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; 62 --match 29 28 27 26 25 63 --end 64 --task 4 65 DROP TABLE IF EXISTS t4; 66 CREATE TABLE t4(a INTEGER PRIMARY KEY, b); 67 INSERT INTO t4 SELECT a, b FROM t1; 68 UPDATE t1 SET b='x'||a||'y'; 69 SELECT sum(length(b)) FROM t4; 70 --match 247 71 SELECT a FROM t4 WHERE b='x17y'; 72 --match 17 73 CREATE INDEX t4b ON t4(b); 74 SELECT a FROM t4 WHERE b='x17y'; 75 --match 17 76 SELECT a FROM t4 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; 77 --match 29 28 27 26 25 78 --end 79 --task 5 80 DROP TABLE IF EXISTS t5; 81 CREATE TABLE t5(a INTEGER PRIMARY KEY, b); 82 INSERT INTO t5 SELECT a, b FROM t1; 83 UPDATE t1 SET b='x'||a||'y'; 84 SELECT sum(length(b)) FROM t5; 85 --match 247 86 SELECT a FROM t5 WHERE b='x17y'; 87 --match 17 88 CREATE INDEX t5b ON t5(b); 89 SELECT a FROM t5 WHERE b='x17y'; 90 --match 17 91 SELECT a FROM t5 WHERE b GLOB 'x2?y' ORDER BY b DESC LIMIT 5; 92 --match 29 28 27 26 25 93 --end 94 95 --wait all 96 /* After the database file has been set up, run the crash2 subscript 97 ** multiple times. */ 98 --source crash02.subtest 99 --source crash02.subtest 100 --source crash02.subtest 101 --source crash02.subtest 102 --source crash02.subtest 103 --source crash02.subtest 104 --source crash02.subtest 105 --source crash02.subtest 106 --source crash02.subtest