15dcb3937Sdan# 2010 February 16 25dcb3937Sdan# 35dcb3937Sdan# The author disclaims copyright to this source code. In place of 45dcb3937Sdan# a legal notice, here is a blessing: 55dcb3937Sdan# 65dcb3937Sdan# May you do good and not evil. 75dcb3937Sdan# May you find forgiveness for yourself and forgive others. 85dcb3937Sdan# May you share freely, never taking more than you give. 95dcb3937Sdan# 105dcb3937Sdan#*********************************************************************** 115dcb3937Sdan# 125dcb3937Sdan# Test that nothing goes wrong if an rtree table is created, then the 135dcb3937Sdan# database page-size is modified. At one point (3.6.22), this was causing 145dcb3937Sdan# malfunctions. 155dcb3937Sdan# 165dcb3937Sdan 175dcb3937Sdanif {![info exists testdir]} { 18897230ebSdan set testdir [file join [file dirname [info script]] .. .. test] 195dcb3937Sdan} 20*1917e92fSdansource [file join [file dirname [info script]] rtree_util.tcl] 215dcb3937Sdansource $testdir/tester.tcl 225dcb3937Sdan 235dcb3937Sdanifcapable !rtree||!vacuum { 245dcb3937Sdan finish_test 255dcb3937Sdan return 265dcb3937Sdan} 275dcb3937Sdan 28f439fbdaSdrh# Like execsql except display output as integer where that can be 29f439fbdaSdrh# done without loss of information. 30f439fbdaSdrh# 31f439fbdaSdrhproc execsql_intout {sql} { 32f439fbdaSdrh set out {} 33f439fbdaSdrh foreach term [execsql $sql] { 34f439fbdaSdrh regsub {\.0$} $term {} term 35f439fbdaSdrh lappend out $term 36f439fbdaSdrh } 37f439fbdaSdrh return $out 38f439fbdaSdrh} 39f439fbdaSdrh 405dcb3937Sdando_test rtree7-1.1 { 415dcb3937Sdan execsql { 425dcb3937Sdan PRAGMA page_size = 1024; 435dcb3937Sdan CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2); 445dcb3937Sdan INSERT INTO rt VALUES(1, 1, 2, 3, 4); 455dcb3937Sdan } 465dcb3937Sdan} {} 475dcb3937Sdando_test rtree7-1.2 { 48f439fbdaSdrh execsql_intout { SELECT * FROM rt } 49f439fbdaSdrh} {1 1 2 3 4} 505dcb3937Sdando_test rtree7-1.3 { 51f439fbdaSdrh execsql_intout { 525dcb3937Sdan PRAGMA page_size = 2048; 535dcb3937Sdan VACUUM; 545dcb3937Sdan SELECT * FROM rt; 555dcb3937Sdan } 56f439fbdaSdrh} {1 1 2 3 4} 575dcb3937Sdando_test rtree7-1.4 { 585dcb3937Sdan for {set i 2} {$i <= 51} {incr i} { 595dcb3937Sdan execsql { INSERT INTO rt VALUES($i, 1, 2, 3, 4) } 605dcb3937Sdan } 61f439fbdaSdrh execsql_intout { SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt } 62f439fbdaSdrh} {51 102 153 204} 635dcb3937Sdando_test rtree7-1.5 { 64f439fbdaSdrh execsql_intout { 655dcb3937Sdan PRAGMA page_size = 512; 665dcb3937Sdan VACUUM; 675dcb3937Sdan SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt 685dcb3937Sdan } 69f439fbdaSdrh} {51 102 153 204} 705dcb3937Sdan 71*1917e92fSdando_rtree_integrity_test rtree7-1.6 rt 72*1917e92fSdan 735dcb3937Sdanfinish_test 74