SQLite

Check-in [985d3bec07]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add tests to backup.test to verify that SQLite behaves as expected when the source database is modified mid-backup.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 985d3bec07430536485056bcd2ae0471791601ed
User & Date: dan 2010-01-13 14:08:01.000
Context
2010-01-13
15:15
Make the doubleToInt64() routine a pass-through when using OMIT_FLOATING_POINT. (check-in: 417167182e user: drh tags: trunk)
14:08
Add tests to backup.test to verify that SQLite behaves as expected when the source database is modified mid-backup. (check-in: 985d3bec07 user: dan tags: trunk)
04:22
Comment out unused code when SQLITE_OMIT_FLOATING_POINT is selected. Added testcase() macros to boundary conditions in util.c routines. (check-in: dfc6595d34 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/backup.test.
900
901
902
903
904
905
906


























































907
    execsql { PRAGMA integrity_check } db3
  } {ok}

  db2 close
  db3 close
}



























































finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
    execsql { PRAGMA integrity_check } db3
  } {ok}

  db2 close
  db3 close
}


# Test that if the database is written to via the same database handle being
# used as the source by a backup operation:
#
#   10.1.*: If the db is in-memory, the backup is restarted.
#   10.2.*: If the db is a file, the backup is not restarted.
#
db close
file delete -force test.db test.db-journal
foreach {tn file rc} {
  1 test.db  SQLITE_DONE
  2 :memory: SQLITE_OK
} {
  do_test backup-10.$tn.1 {
    sqlite3 db $file
    execsql { 
      CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);
      BEGIN;
        INSERT INTO t1 VALUES(NULL, randomblob(200));
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;
      COMMIT;
      SELECT count(*) FROM t1;
    }
  } {256}

  do_test backup-10.$tn.2 {
    set pgs [execsql {pragma page_count}]
    expr {$pgs > 50 && $pgs < 75}
  } {1}

  do_test backup-10.$tn.3 {
    file delete -force bak.db bak.db-journal
    sqlite3 db2 bak.db
    sqlite3_backup B db2 main db main
    B step 50
  } {SQLITE_OK}

  do_test backup-10.$tn.4 {
    execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) }
  } {}

  do_test backup-10.$tn.5 {
    B step 50
  } $rc

  do_test backup-10.6 {
    B finish
  } {SQLITE_OK}
}

db2 close
finish_test