OLD | NEW |
1 # 2010 February 16 | 1 # 2010 February 16 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
11 # | 11 # |
12 # Test that nothing goes wrong if an rtree table is created, then the | 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 | 13 # database page-size is modified. At one point (3.6.22), this was causing |
14 # malfunctions. | 14 # malfunctions. |
15 # | 15 # |
16 | 16 |
17 if {![info exists testdir]} { | 17 if {![info exists testdir]} { |
18 set testdir [file join [file dirname [info script]] .. .. test] | 18 set testdir [file join [file dirname [info script]] .. .. test] |
19 } | 19 } |
20 source $testdir/tester.tcl | 20 source $testdir/tester.tcl |
21 | 21 |
22 ifcapable !rtree||!vacuum { | 22 ifcapable !rtree||!vacuum { |
23 finish_test | 23 finish_test |
24 return | 24 return |
25 } | 25 } |
26 | 26 |
| 27 # Like execsql except display output as integer where that can be |
| 28 # done without loss of information. |
| 29 # |
| 30 proc execsql_intout {sql} { |
| 31 set out {} |
| 32 foreach term [execsql $sql] { |
| 33 regsub {\.0$} $term {} term |
| 34 lappend out $term |
| 35 } |
| 36 return $out |
| 37 } |
| 38 |
27 do_test rtree7-1.1 { | 39 do_test rtree7-1.1 { |
28 execsql { | 40 execsql { |
29 PRAGMA page_size = 1024; | 41 PRAGMA page_size = 1024; |
30 CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2); | 42 CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2); |
31 INSERT INTO rt VALUES(1, 1, 2, 3, 4); | 43 INSERT INTO rt VALUES(1, 1, 2, 3, 4); |
32 } | 44 } |
33 } {} | 45 } {} |
34 do_test rtree7-1.2 { | 46 do_test rtree7-1.2 { |
35 execsql { SELECT * FROM rt } | 47 execsql_intout { SELECT * FROM rt } |
36 } {1 1.0 2.0 3.0 4.0} | 48 } {1 1 2 3 4} |
37 do_test rtree7-1.3 { | 49 do_test rtree7-1.3 { |
38 execsql { | 50 execsql_intout { |
39 PRAGMA page_size = 2048; | 51 PRAGMA page_size = 2048; |
40 VACUUM; | 52 VACUUM; |
41 SELECT * FROM rt; | 53 SELECT * FROM rt; |
42 } | 54 } |
43 } {1 1.0 2.0 3.0 4.0} | 55 } {1 1 2 3 4} |
44 do_test rtree7-1.4 { | 56 do_test rtree7-1.4 { |
45 for {set i 2} {$i <= 51} {incr i} { | 57 for {set i 2} {$i <= 51} {incr i} { |
46 execsql { INSERT INTO rt VALUES($i, 1, 2, 3, 4) } | 58 execsql { INSERT INTO rt VALUES($i, 1, 2, 3, 4) } |
47 } | 59 } |
48 execsql { SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt } | 60 execsql_intout { SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt } |
49 } {51.0 102.0 153.0 204.0} | 61 } {51 102 153 204} |
50 do_test rtree7-1.5 { | 62 do_test rtree7-1.5 { |
51 execsql { | 63 execsql_intout { |
52 PRAGMA page_size = 512; | 64 PRAGMA page_size = 512; |
53 VACUUM; | 65 VACUUM; |
54 SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt | 66 SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt |
55 } | 67 } |
56 } {51.0 102.0 153.0 204.0} | 68 } {51 102 153 204} |
57 | 69 |
58 finish_test | 70 finish_test |
OLD | NEW |