summaryrefslogtreecommitdiffstats
path: root/ext/rtree/rtree6.test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:28:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:28:19 +0000
commit18657a960e125336f704ea058e25c27bd3900dcb (patch)
tree17b438b680ed45a996d7b59951e6aa34023783f2 /ext/rtree/rtree6.test
parentInitial commit. (diff)
downloadsqlite3-upstream.tar.xz
sqlite3-upstream.zip
Adding upstream version 3.40.1.upstream/3.40.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--ext/rtree/rtree6.test181
1 files changed, 181 insertions, 0 deletions
diff --git a/ext/rtree/rtree6.test b/ext/rtree/rtree6.test
new file mode 100644
index 0000000..b6dfe99
--- /dev/null
+++ b/ext/rtree/rtree6.test
@@ -0,0 +1,181 @@
+# 2008 Sep 1
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+#
+
+if {![info exists testdir]} {
+ set testdir [file join [file dirname [info script]] .. .. test]
+}
+source $testdir/tester.tcl
+set testprefix rtree6
+
+ifcapable {!rtree || rtree_int_only} {
+ finish_test
+ return
+}
+
+# Operator Byte Value
+# ----------------------
+# = 0x41 ('A')
+# <= 0x42 ('B')
+# < 0x43 ('C')
+# >= 0x44 ('D')
+# > 0x45 ('E')
+# ----------------------
+
+proc rtree_strategy {sql} {
+ set ret [list]
+ db eval "explain $sql" a {
+ if {$a(opcode) eq "VFilter"} {
+ lappend ret $a(p4)
+ }
+ }
+ set ret
+}
+
+proc query_plan {sql} {
+ set ret [list]
+ db eval "explain query plan $sql" a {
+ lappend ret $a(detail)
+ }
+ set ret
+}
+
+do_test rtree6-1.1 {
+ execsql {
+ CREATE TABLE t2(k INTEGER PRIMARY KEY, v);
+ CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);
+ }
+} {}
+
+do_test rtree6-1.2 {
+ rtree_strategy {SELECT * FROM t1 WHERE x1>10}
+} {E0}
+do_test rtree6-1.2.1 {
+ rtree_strategy {SELECT * FROM t1 WHERE x1>10 AND x2 LIKE '%x%'}
+} {E0}
+
+do_test rtree6-1.3 {
+ rtree_strategy {SELECT * FROM t1 WHERE x1<10}
+} {C0}
+
+do_test rtree6-1.4 {
+ rtree_strategy {SELECT * FROM t1,t2 WHERE k=ii AND x1<10}
+} {C0}
+
+do_test rtree6-1.5 {
+ rtree_strategy {SELECT * FROM t1,t2 WHERE k=+ii AND x1<10}
+} {C0}
+
+do_eqp_test rtree6.2.1 {
+ SELECT * FROM t1,t2 WHERE k=+ii AND x1<10
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 2:C0
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+do_eqp_test rtree6.2.2 {
+ SELECT * FROM t1,t2 WHERE k=ii AND x1<10
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 2:C0
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+do_eqp_test rtree6.2.3 {
+ SELECT * FROM t1,t2 WHERE k=ii
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 2:
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+do_eqp_test rtree6.2.4.1 {
+ SELECT * FROM t1,t2 WHERE v=+ii and x1<10 and x2>10
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 2:C0E1
+ `--SEARCH t2 USING AUTOMATIC COVERING INDEX (v=?)
+}
+do_eqp_test rtree6.2.4.2 {
+ SELECT * FROM t1,t2 WHERE v=10 and x1<10 and x2>10
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 2:C0E1
+ `--SEARCH t2 USING AUTOMATIC PARTIAL COVERING INDEX (v=?)
+}
+
+do_eqp_test rtree6.2.5 {
+ SELECT * FROM t1,t2 WHERE k=ii AND x1<v
+} {
+ QUERY PLAN
+ |--SCAN t1 VIRTUAL TABLE INDEX 2:
+ `--SEARCH t2 USING INTEGER PRIMARY KEY (rowid=?)
+}
+
+do_execsql_test rtree6-3.1 {
+ CREATE VIRTUAL TABLE t3 USING rtree(id, x1, x2, y1, y2);
+ INSERT INTO t3 VALUES(NULL, 1, 1, 2, 2);
+ SELECT * FROM t3 WHERE
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5;
+} {1 1.0 1.0 2.0 2.0}
+
+do_test rtree6.3.2 {
+ rtree_strategy {
+ SELECT * FROM t3 WHERE
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5
+ }
+} {E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0}
+do_test rtree6.3.3 {
+ rtree_strategy {
+ SELECT * FROM t3 WHERE
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5
+ }
+} {E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0}
+
+do_execsql_test rtree6-3.4 {
+ SELECT * FROM t3 WHERE x1>0.5 AND x1>0.8 AND x1>1.1
+} {}
+do_execsql_test rtree6-3.5 {
+ SELECT * FROM t3 WHERE
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND
+ x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>1.1
+} {}
+
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE VIRTUAL TABLE t1 USING rtree(id,x0,x1,y0,y1);
+}
+do_execsql_test 4.1 {
+ DELETE FROM t1 WHERE x0>1 AND x1<2 OR y0<92;
+}
+
+expand_all_sql db
+finish_test