gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/subjournal.test (about)

     1  # 2017 May 9
     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  
    13  set testdir [file dirname $argv0]
    14  source $testdir/tester.tcl
    15  set testprefix subjournal
    16  
    17  do_execsql_test 1.0 {
    18    PRAGMA temp_store = memory;
    19    CREATE TABLE t1(a,b,c);
    20    INSERT INTO t1 VALUES(1, 2, 3);
    21  } {}
    22  do_execsql_test 1.1 {
    23    BEGIN;
    24      INSERT INTO t1 VALUES(4, 5, 6);
    25      SAVEPOINT one;
    26        INSERT INTO t1 VALUES(7, 8, 9);
    27      ROLLBACK TO one;
    28      SELECT * FROM t1;
    29  } {1 2 3 4 5 6}
    30  do_execsql_test 1.2 {
    31    COMMIT;
    32  }
    33  
    34  do_execsql_test 2.0 {
    35    PRAGMA cache_size = 5;
    36    CREATE TABLE t2(a BLOB);
    37    CREATE INDEX i2 ON t2(a);
    38    WITH s(i) AS (
    39      SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
    40    ) INSERT INTO t2 SELECT randomblob(500) FROM s;
    41  }
    42  
    43  do_test 2.1 {
    44    forcedelete test.db2
    45    sqlite3 db2 test2.db
    46    sqlite3_backup B db2 main db main
    47    set nPage [db one {PRAGMA page_count}]
    48    B step [expr $nPage-10]
    49  } {SQLITE_OK}
    50  
    51  do_execsql_test 2.2 {
    52    BEGIN;
    53      UPDATE t2 SET a=randomblob(499);
    54      SAVEPOINT two;
    55        UPDATE t2 SET a=randomblob(498);
    56      ROLLBACK TO two;
    57    COMMIT;
    58    PRAGMA integrity_check;
    59  } {ok}
    60  
    61  do_test 2.3 {
    62    B step 1000
    63  } {SQLITE_DONE}
    64  do_test 2.4 {
    65    B finish
    66    execsql { PRAGMA integrity_check } db2
    67  } {ok}
    68  
    69  finish_test