rtree7.test 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # 2010 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 that nothing goes wrong if an rtree table is created, then the
  13. # database page-size is modified. At one point (3.6.22), this was causing
  14. # malfunctions.
  15. #
  16. if {![info exists testdir]} {
  17. set testdir [file join [file dirname [info script]] .. .. test]
  18. }
  19. source [file join [file dirname [info script]] rtree_util.tcl]
  20. source $testdir/tester.tcl
  21. ifcapable !rtree||!vacuum {
  22. finish_test
  23. return
  24. }
  25. # Like execsql except display output as integer where that can be
  26. # done without loss of information.
  27. #
  28. proc execsql_intout {sql} {
  29. set out {}
  30. foreach term [execsql $sql] {
  31. regsub {\.0$} $term {} term
  32. lappend out $term
  33. }
  34. return $out
  35. }
  36. do_test rtree7-1.1 {
  37. execsql {
  38. PRAGMA page_size = 1024;
  39. CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2);
  40. INSERT INTO rt VALUES(1, 1, 2, 3, 4);
  41. }
  42. } {}
  43. do_test rtree7-1.2 {
  44. execsql_intout { SELECT * FROM rt }
  45. } {1 1 2 3 4}
  46. do_test rtree7-1.3 {
  47. execsql_intout {
  48. PRAGMA page_size = 2048;
  49. VACUUM;
  50. SELECT * FROM rt;
  51. }
  52. } {1 1 2 3 4}
  53. do_test rtree7-1.4 {
  54. for {set i 2} {$i <= 51} {incr i} {
  55. execsql { INSERT INTO rt VALUES($i, 1, 2, 3, 4) }
  56. }
  57. execsql_intout { SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt }
  58. } {51 102 153 204}
  59. do_test rtree7-1.5 {
  60. execsql_intout {
  61. PRAGMA page_size = 512;
  62. VACUUM;
  63. SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt
  64. }
  65. } {51 102 153 204}
  66. do_rtree_integrity_test rtree7-1.6 rt
  67. finish_test