1
0

rtree7.test 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 $testdir/tester.tcl
  20. ifcapable !rtree||!vacuum {
  21. finish_test
  22. return
  23. }
  24. # Like execsql except display output as integer where that can be
  25. # done without loss of information.
  26. #
  27. proc execsql_intout {sql} {
  28. set out {}
  29. foreach term [execsql $sql] {
  30. regsub {\.0$} $term {} term
  31. lappend out $term
  32. }
  33. return $out
  34. }
  35. do_test rtree7-1.1 {
  36. execsql {
  37. PRAGMA page_size = 1024;
  38. CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2);
  39. INSERT INTO rt VALUES(1, 1, 2, 3, 4);
  40. }
  41. } {}
  42. do_test rtree7-1.2 {
  43. execsql_intout { SELECT * FROM rt }
  44. } {1 1 2 3 4}
  45. do_test rtree7-1.3 {
  46. execsql_intout {
  47. PRAGMA page_size = 2048;
  48. VACUUM;
  49. SELECT * FROM rt;
  50. }
  51. } {1 1 2 3 4}
  52. do_test rtree7-1.4 {
  53. for {set i 2} {$i <= 51} {incr i} {
  54. execsql { INSERT INTO rt VALUES($i, 1, 2, 3, 4) }
  55. }
  56. execsql_intout { SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt }
  57. } {51 102 153 204}
  58. do_test rtree7-1.5 {
  59. execsql_intout {
  60. PRAGMA page_size = 512;
  61. VACUUM;
  62. SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt
  63. }
  64. } {51 102 153 204}
  65. finish_test