| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | if {![info exists testdir]} { |
| | set testdir [file join [file dirname [info script]] .. .. test] |
| | } |
| | source [file join [file dirname [info script]] rtree_util.tcl] |
| | source $testdir/tester.tcl |
| |
|
| | ifcapable !rtree { |
| | finish_test |
| | return |
| | } |
| |
|
| | set ::NROW 1000 |
| | set ::NDEL 10 |
| | set ::NSELECT 100 |
| |
|
| | if {[info exists G(isquick)] && $G(isquick)} { |
| | set ::NROW 100 |
| | set ::NSELECT 10 |
| | } |
| |
|
| | foreach module {rtree_i32 rtree} { |
| | if {$module=="rtree_i32"} {set etype INT} {set etype REAL} |
| | for {set nDim 1} {$nDim <= 5} {incr nDim} { |
| | |
| | do_test rtree2-$module.$nDim.1 { |
| | set cols [list] |
| | foreach c [list c0 c1 c2 c3 c4 c5 c6 c7 c8 c9] { |
| | lappend cols "$c $etype" |
| | } |
| | set cols [join [lrange $cols 0 [expr {$nDim*2-1}]] ", "] |
| | execsql " |
| | CREATE VIRTUAL TABLE t1 USING ${module}(ii, $cols); |
| | CREATE TABLE t2 (ii, $cols); |
| | " |
| | } {} |
| | |
| | do_test rtree2-$module.$nDim.2 { |
| | db transaction { |
| | for {set ii 0} {$ii < $::NROW} {incr ii} { |
| | |
| | set values [list] |
| | for {set jj 0} {$jj<$nDim*2} {incr jj} { |
| | lappend values [expr int(rand()*1000)] |
| | } |
| | set values [join $values ,] |
| | |
| | |
| | set rc [catch {db eval "INSERT INTO t1 VALUES($ii, $values)"}] |
| | if {$rc} { |
| | incr ii -1 |
| | } else { |
| | db eval "INSERT INTO t2 VALUES($ii, $values)" |
| | } |
| | |
| | |
| | |
| | |
| | } |
| | } |
| | |
| | set t1 [execsql {SELECT * FROM t1 ORDER BY ii}] |
| | set t2 [execsql {SELECT * FROM t2 ORDER BY ii}] |
| | set rc [expr {$t1 eq $t2}] |
| | if {$rc != 1} { |
| | puts $t1 |
| | puts $t2 |
| | } |
| | set rc |
| | } {1} |
| | |
| | do_rtree_integrity_test rtree2-$module.$nDim.3 t1 |
| | |
| | set OPS [list < > <= >= =] |
| | for {set ii 0} {$ii < $::NSELECT} {incr ii} { |
| | do_test rtree2-$module.$nDim.4.$ii.1 { |
| | set where [list] |
| | foreach look_three_dots! {. . .} { |
| | set colidx [expr int(rand()*($nDim*2+1))-1] |
| | if {$colidx<0} { |
| | set col ii |
| | } else { |
| | set col "c$colidx" |
| | } |
| | set op [lindex $OPS [expr int(rand()*[llength $OPS])]] |
| | set val [expr int(rand()*1000)] |
| | lappend where "$col $op $val" |
| | } |
| | set where [join $where " AND "] |
| | |
| | set t1 [execsql "SELECT * FROM t1 WHERE $where ORDER BY ii"] |
| | set t2 [execsql "SELECT * FROM t2 WHERE $where ORDER BY ii"] |
| | set rc [expr {$t1 eq $t2}] |
| | if {$rc != 1} { |
| | |
| | puts $t1 |
| | puts $t2 |
| | |
| | |
| | |
| | |
| | } |
| | set rc |
| | } {1} |
| | } |
| | |
| | for {set ii 0} {$ii < $::NROW} {incr ii $::NDEL} { |
| | |
| | do_test rtree2-$module.$nDim.5.$ii.1 { |
| | execsql "DELETE FROM t2 WHERE ii <= $::ii" |
| | execsql "DELETE FROM t1 WHERE ii <= $::ii" |
| | |
| | set t1 [execsql {SELECT * FROM t1 ORDER BY ii}] |
| | set t2 [execsql {SELECT * FROM t2 ORDER BY ii}] |
| | set rc [expr {$t1 eq $t2}] |
| | if {$rc != 1} { |
| | puts $t1 |
| | puts $t2 |
| | } |
| | set rc |
| | } {1} |
| | do_rtree_integrity_test rtree2-$module.$nDim.5.$ii.2 t1 |
| | } |
| | |
| | do_test rtree2-$module.$nDim.6 { |
| | execsql { |
| | DROP TABLE t1; |
| | DROP TABLE t2; |
| | } |
| | } {} |
| | } |
| | } |
| |
|
| | finish_test |
| |
|