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