rbuvacuum3.test 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # 2019 Jan 3
  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. # This file contains tests for the RBU module. More specifically, it
  13. # contains tests to ensure that the sqlite3rbu_vacuum() API works as
  14. # expected.
  15. #
  16. source [file join [file dirname [info script]] rbu_common.tcl]
  17. if_no_rbu_support { finish_test ; return }
  18. set testprefix rbuvacuum3
  19. do_execsql_test 1.0 {
  20. CREATE TABLE t1(a PRIMARY KEY, b, c);
  21. CREATE INDEX i1b ON t1(b);
  22. CREATE INDEX i1c ON t1(c);
  23. WITH s(i) AS (
  24. VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
  25. )
  26. INSERT INTO t1 SELECT i, randomblob(100), randomblob(100) FROM s;
  27. }
  28. forcedelete state.db
  29. do_test 1.1 {
  30. sqlite3rbu_vacuum rbu test.db state.db
  31. while {1} {
  32. set rc [rbu step]
  33. if {$rc!="SQLITE_OK"} break
  34. rbu savestate
  35. }
  36. rbu close
  37. } {SQLITE_DONE}
  38. do_test 1.2 {
  39. sqlite3rbu_vacuum rbu test.db state.db
  40. while {1} {
  41. set rc [rbu step]
  42. if {$rc!="SQLITE_OK"} break
  43. rbu savestate
  44. }
  45. rbu close
  46. } {SQLITE_DONE}
  47. do_test 1.3 {
  48. while {1} {
  49. sqlite3rbu_vacuum rbu test.db state.db
  50. set rc [rbu step]
  51. if {$rc!="SQLITE_OK"} break
  52. rbu savestate
  53. rbu close
  54. }
  55. rbu close
  56. } {SQLITE_DONE}
  57. finish_test