recoverrowid.test 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # 2022 September 07
  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. # Tests for the SQLITE_RECOVER_ROWIDS option.
  13. #
  14. source [file join [file dirname [info script]] recover_common.tcl]
  15. set testprefix recoverrowid
  16. proc recover {db bRowids output} {
  17. forcedelete $output
  18. set R [sqlite3_recover_init db main test.db2]
  19. $R config rowids $bRowids
  20. $R run
  21. $R finish
  22. }
  23. do_execsql_test 1.0 {
  24. CREATE TABLE t1(a, b);
  25. INSERT INTO t1 VALUES(1, 1), (2, 2), (3, 3), (4, 4);
  26. DELETE FROM t1 WHERE a IN (1, 3);
  27. }
  28. do_test 1.1 {
  29. recover db 0 test.db2
  30. sqlite3 db2 test.db2
  31. execsql { SELECT rowid, a, b FROM t1 ORDER BY rowid} db2
  32. } {1 2 2 2 4 4}
  33. do_test 1.2 {
  34. db2 close
  35. recover db 1 test.db2
  36. sqlite3 db2 test.db2
  37. execsql { SELECT rowid, a, b FROM t1 ORDER BY rowid} db2
  38. } {2 2 2 4 4 4}
  39. db2 close
  40. finish_test