rbu8.test 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # 2014 November 20
  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. # Test the rbu_delta() feature.
  13. #
  14. source [file join [file dirname [info script]] rbu_common.tcl]
  15. if_no_rbu_support { finish_test ; return }
  16. set ::testprefix rbu8
  17. do_execsql_test 1.0 {
  18. CREATE TABLE t1(x, y PRIMARY KEY, z);
  19. INSERT INTO t1 VALUES(NULL, 1, 'one');
  20. INSERT INTO t1 VALUES(NULL, 2, 'two');
  21. INSERT INTO t1 VALUES(NULL, 3, 'three');
  22. CREATE INDEX i1z ON t1(z, x);
  23. }
  24. do_test 1.1 {
  25. forcedelete rbu.db
  26. sqlite3 db2 rbu.db
  27. db2 eval {
  28. CREATE TABLE data_t1(x, y, z, rbu_control);
  29. INSERT INTO data_t1 VALUES('a', 1, '_i' , 'x.d');
  30. INSERT INTO data_t1 VALUES('b', 2, 2 , '..x');
  31. INSERT INTO data_t1 VALUES('_iii', 3, '-III' , 'd.d');
  32. }
  33. db2 close
  34. } {}
  35. do_test 1.2.1 {
  36. sqlite3rbu rbu test.db rbu.db
  37. rbu step
  38. } {SQLITE_ERROR}
  39. do_test 1.2.2 {
  40. list [catch {rbu close} msg] $msg
  41. } {1 {SQLITE_ERROR - no such function: rbu_delta}}
  42. proc rbu_delta {orig new} {
  43. return "${orig}${new}"
  44. }
  45. do_test 1.3.1 {
  46. while 1 {
  47. sqlite3rbu rbu test.db rbu.db
  48. rbu create_rbu_delta
  49. set rc [rbu step]
  50. if {$rc != "SQLITE_OK"} break
  51. rbu close
  52. }
  53. rbu close
  54. } {SQLITE_DONE}
  55. do_execsql_test 1.3.2 {
  56. SELECT * FROM t1
  57. } {
  58. a 1 one_i
  59. {} 2 2
  60. _iii 3 three-III
  61. }
  62. integrity_check 1.3.3
  63. finish_test