/ Artifact Content
Login

Artifact 640be93f5422df37203aa5e7c06b24fb5e4a2439:


# 2010 July 1
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# Verify that an empty database and a non-empty WAL file do not
# result in database corruption
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
ifcapable !wal {finish_test ; return }

do_test wal4-1.1 {
  db close
  file delete -force wal4.db wal4.db-journal wal4.db-wal wal4.db-shm
  file delete -force test.db test.db-journal test.db-wal test.db-shm
  sqlite3 db2 wal4.db
  db2 eval {
    PRAGMA journal_mode=WAL;
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(1);
    INSERT INTO t1 VALUES(2);
    SELECT x FROM t1 ORDER BY x;
  }
} {wal 1 2}
do_test wal4-1.2 {
  file delete -force test.db test.db-journal test.db-wal
  file copy wal4.db-wal test.db-wal
  sqlite3 db test.db
  catchsql {
    SELECT * FROM t1;
  }
} {1 {no such table: t1}}

do_malloc_test wal4-2.0 -tclprep {
  db close
  file delete -force test.db test.db-journal test.db-wal
  file copy wal4.db-wal test.db-wal
  sqlite3 db test.db
} -sqlbody {
  SELECT name FROM sqlite_master
}  


finish_test