recoverslowidx.test 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # 2022 September 25
  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_SLOWINDEXES option.
  13. #
  14. source [file join [file dirname [info script]] recover_common.tcl]
  15. set testprefix recoverslowidx
  16. do_execsql_test 1.0 {
  17. PRAGMA auto_vacuum = 0;
  18. CREATE TABLE t1(a, b);
  19. CREATE INDEX i1 ON t1(a);
  20. INSERT INTO t1 VALUES(1, 1), (2, 2), (3, 3), (4, 4);
  21. }
  22. proc my_sql_hook {sql} {
  23. lappend ::lSql $sql
  24. return 0
  25. }
  26. do_test 1.1 {
  27. set lSql [list]
  28. set R [sqlite3_recover_init_sql db main my_sql_hook]
  29. while {[$R step]==0} { }
  30. $R finish
  31. } {}
  32. do_test 1.2 {
  33. set lSql
  34. } [list {*}{
  35. {BEGIN}
  36. {PRAGMA writable_schema = on}
  37. {PRAGMA encoding = 'UTF-8'}
  38. {PRAGMA page_size = '1024'}
  39. {PRAGMA auto_vacuum = '0'}
  40. {PRAGMA user_version = '0'}
  41. {PRAGMA application_id = '0'}
  42. {CREATE TABLE t1(a, b)}
  43. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (1, 1, 1)}
  44. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (2, 2, 2)}
  45. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (3, 3, 3)}
  46. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (4, 4, 4)}
  47. {CREATE INDEX i1 ON t1(a)}
  48. {PRAGMA writable_schema = off}
  49. {COMMIT}
  50. }]
  51. do_test 1.3 {
  52. set lSql [list]
  53. set R [sqlite3_recover_init_sql db main my_sql_hook]
  54. $R config slowindexes 1
  55. while {[$R step]==0} { }
  56. $R finish
  57. } {}
  58. do_test 1.4 {
  59. set lSql
  60. } [list {*}{
  61. {BEGIN}
  62. {PRAGMA writable_schema = on}
  63. {PRAGMA encoding = 'UTF-8'}
  64. {PRAGMA page_size = '1024'}
  65. {PRAGMA auto_vacuum = '0'}
  66. {PRAGMA user_version = '0'}
  67. {PRAGMA application_id = '0'}
  68. {CREATE TABLE t1(a, b)}
  69. {CREATE INDEX i1 ON t1(a)}
  70. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (1, 1, 1)}
  71. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (2, 2, 2)}
  72. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (3, 3, 3)}
  73. {INSERT OR IGNORE INTO 't1'(_rowid_, 'a', 'b') VALUES (4, 4, 4)}
  74. {PRAGMA writable_schema = off}
  75. {COMMIT}
  76. }]
  77. finish_test