1*2617c9bdSdan# 2017 May 9 2*2617c9bdSdan# 3*2617c9bdSdan# The author disclaims copyright to this source code. In place of 4*2617c9bdSdan# a legal notice, here is a blessing: 5*2617c9bdSdan# 6*2617c9bdSdan# May you do good and not evil. 7*2617c9bdSdan# May you find forgiveness for yourself and forgive others. 8*2617c9bdSdan# May you share freely, never taking more than you give. 9*2617c9bdSdan# 10*2617c9bdSdan#*********************************************************************** 11*2617c9bdSdan# 12*2617c9bdSdan 13*2617c9bdSdanset testdir [file dirname $argv0] 14*2617c9bdSdansource $testdir/tester.tcl 15*2617c9bdSdanset testprefix subjournal 16*2617c9bdSdan 17*2617c9bdSdando_execsql_test 1.0 { 18*2617c9bdSdan PRAGMA temp_store = memory; 19*2617c9bdSdan CREATE TABLE t1(a,b,c); 20*2617c9bdSdan INSERT INTO t1 VALUES(1, 2, 3); 21*2617c9bdSdan} {} 22*2617c9bdSdando_execsql_test 1.1 { 23*2617c9bdSdan BEGIN; 24*2617c9bdSdan INSERT INTO t1 VALUES(4, 5, 6); 25*2617c9bdSdan SAVEPOINT one; 26*2617c9bdSdan INSERT INTO t1 VALUES(7, 8, 9); 27*2617c9bdSdan ROLLBACK TO one; 28*2617c9bdSdan SELECT * FROM t1; 29*2617c9bdSdan} {1 2 3 4 5 6} 30*2617c9bdSdando_execsql_test 1.2 { 31*2617c9bdSdan COMMIT; 32*2617c9bdSdan} 33*2617c9bdSdan 34*2617c9bdSdando_execsql_test 2.0 { 35*2617c9bdSdan PRAGMA cache_size = 5; 36*2617c9bdSdan CREATE TABLE t2(a BLOB); 37*2617c9bdSdan CREATE INDEX i2 ON t2(a); 38*2617c9bdSdan WITH s(i) AS ( 39*2617c9bdSdan SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 40*2617c9bdSdan ) INSERT INTO t2 SELECT randomblob(500) FROM s; 41*2617c9bdSdan} 42*2617c9bdSdan 43*2617c9bdSdando_test 2.1 { 44*2617c9bdSdan forcedelete test.db2 45*2617c9bdSdan sqlite3 db2 test2.db 46*2617c9bdSdan sqlite3_backup B db2 main db main 47*2617c9bdSdan set nPage [db one {PRAGMA page_count}] 48*2617c9bdSdan B step [expr $nPage-10] 49*2617c9bdSdan} {SQLITE_OK} 50*2617c9bdSdan 51*2617c9bdSdando_execsql_test 2.2 { 52*2617c9bdSdan BEGIN; 53*2617c9bdSdan UPDATE t2 SET a=randomblob(499); 54*2617c9bdSdan SAVEPOINT two; 55*2617c9bdSdan UPDATE t2 SET a=randomblob(498); 56*2617c9bdSdan ROLLBACK TO two; 57*2617c9bdSdan COMMIT; 58*2617c9bdSdan PRAGMA integrity_check; 59*2617c9bdSdan} {ok} 60*2617c9bdSdan 61*2617c9bdSdando_test 2.3 { 62*2617c9bdSdan B step 1000 63*2617c9bdSdan} {SQLITE_DONE} 64*2617c9bdSdando_test 2.4 { 65*2617c9bdSdan B finish 66*2617c9bdSdan execsql { PRAGMA integrity_check } db2 67*2617c9bdSdan} {ok} 68*2617c9bdSdan 69*2617c9bdSdanfinish_test 70