rbu13.test 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # 2015 February 16
  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 an RBU update that features lots of different rbu_control strings
  13. # for UPDATE statements. This tests RBU's internal UPDATE statement cache.
  14. #
  15. source [file join [file dirname [info script]] rbu_common.tcl]
  16. if_no_rbu_support { finish_test ; return }
  17. source $testdir/lock_common.tcl
  18. set ::testprefix rbu13
  19. do_execsql_test 1.0 {
  20. CREATE TABLE t1(a PRIMARY KEY, b, c, d, e, f, g, h);
  21. WITH ii(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM ii WHERE i<127)
  22. INSERT INTO t1 SELECT i, 0, 0, 0, 0, 0, 0, 0 FROM ii;
  23. }
  24. forcedelete rbu.db
  25. do_execsql_test 1.1 {
  26. ATTACH 'rbu.db' AS rbu;
  27. CREATE TABLE rbu.data_t1(a, b, c, d, e, f, g, h, rbu_control);
  28. }
  29. do_test 1.2 {
  30. for {set i 0} {$i<128} {incr i} {
  31. set control "."
  32. for {set bit 6} {$bit>=0} {incr bit -1} {
  33. if { $i & (1<<$bit) } {
  34. append control "x"
  35. } else {
  36. append control "."
  37. }
  38. }
  39. execsql { INSERT INTO data_t1 VALUES($i, 1, 1, 1, 1, 1, 1, 1, $control) }
  40. }
  41. } {}
  42. do_test 1.3 {
  43. sqlite3rbu rbu test.db rbu.db
  44. while 1 {
  45. set rc [rbu step]
  46. if {$rc!="SQLITE_OK"} break
  47. }
  48. rbu close
  49. } {SQLITE_DONE}
  50. do_execsql_test 1.4 {
  51. SELECT count(*) FROM t1 WHERE
  52. a == ( (b<<6) + (c<<5) + (d<<4) + (e<<3) + (f<<2) + (g<<1) + (h<<0) )
  53. } {128}
  54. finish_test