3
# The author disclaims copyright to this source code. In place of
4
# a legal notice, here is a blessing:
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.
10
#***********************************************************************
14
if {![info exists testdir]} {
15
set testdir [file join [file dirname $argv0] .. .. test]
17
source $testdir/tester.tcl
25
# ----------------------
31
# ----------------------
33
proc rtree_strategy {sql} {
35
db eval "explain $sql" a {
36
if {$a(opcode) eq "VFilter"} {
43
proc query_plan {sql} {
45
db eval "explain query plan $sql" a {
46
lappend ret $a(detail)
53
CREATE TABLE t2(k INTEGER PRIMARY KEY, v);
54
CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);
59
rtree_strategy {SELECT * FROM t1 WHERE x1>10}
63
rtree_strategy {SELECT * FROM t1 WHERE x1<10}
67
rtree_strategy {SELECT * FROM t1,t2 WHERE k=ii AND x1<10}
71
rtree_strategy {SELECT * FROM t1,t2 WHERE k=+ii AND x1<10}
75
query_plan {SELECT * FROM t1,t2 WHERE k=+ii AND x1<10}
77
{TABLE t1 VIRTUAL TABLE INDEX 2:Ca} \
78
{TABLE t2 USING PRIMARY KEY} \
82
query_plan {SELECT * FROM t1,t2 WHERE k=ii AND x1<10}
84
{TABLE t1 VIRTUAL TABLE INDEX 2:Ca} \
85
{TABLE t2 USING PRIMARY KEY} \
89
query_plan {SELECT * FROM t1,t2 WHERE k=ii}
92
{TABLE t1 VIRTUAL TABLE INDEX 1:} \
96
query_plan {SELECT * FROM t1,t2 WHERE v=10 and x1<10 and x2>10}
98
{TABLE t1 VIRTUAL TABLE INDEX 2:CaEb} \
103
query_plan {SELECT * FROM t1,t2 WHERE k=ii AND x1<v}
106
{TABLE t1 VIRTUAL TABLE INDEX 1:} \