~ubuntu-branches/ubuntu/saucy/db/saucy-proposed

« back to all changes in this revision

Viewing changes to lang/sql/sqlite/ext/rtree/rtree6.test

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-11-05 15:02:09 UTC
  • mfrom: (13.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20101105150209-ppvyn0619pu014xo
Tags: 5.1.19-1ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Pass --build/--host to configure to support cross-building, and don't
    override CC.
  - Disable the Java build when cross-building, for now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# 2008 Sep 1
 
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
#
 
13
 
 
14
if {![info exists testdir]} {
 
15
  set testdir [file join [file dirname $argv0] .. .. test]
 
16
 
17
source $testdir/tester.tcl
 
18
 
 
19
ifcapable !rtree {
 
20
  finish_test
 
21
  return
 
22
}
 
23
 
 
24
#   Operator    Byte Value
 
25
#   ----------------------
 
26
#      =        0x41 ('A')
 
27
#     <=        0x42 ('B')
 
28
#      <        0x43 ('C')
 
29
#     >=        0x44 ('D')
 
30
#      >        0x45 ('E')
 
31
#   ----------------------
 
32
 
 
33
proc rtree_strategy {sql} {
 
34
  set ret [list]
 
35
  db eval "explain $sql" a {
 
36
    if {$a(opcode) eq "VFilter"} {
 
37
      lappend ret $a(p4)
 
38
    }
 
39
  }
 
40
  set ret
 
41
}
 
42
 
 
43
proc query_plan {sql} {
 
44
  set ret [list]
 
45
  db eval "explain query plan $sql" a {
 
46
    lappend ret $a(detail)
 
47
  }
 
48
  set ret
 
49
}
 
50
 
 
51
do_test rtree6-1.1 {
 
52
  execsql {
 
53
    CREATE TABLE t2(k INTEGER PRIMARY KEY, v);
 
54
    CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);
 
55
  }
 
56
} {}
 
57
 
 
58
do_test rtree6-1.2 {
 
59
  rtree_strategy {SELECT * FROM t1 WHERE x1>10}
 
60
} {Ea}
 
61
 
 
62
do_test rtree6-1.3 {
 
63
  rtree_strategy {SELECT * FROM t1 WHERE x1<10}
 
64
} {Ca}
 
65
 
 
66
do_test rtree6-1.4 {
 
67
  rtree_strategy {SELECT * FROM t1,t2 WHERE k=ii AND x1<10}
 
68
} {Ca}
 
69
 
 
70
do_test rtree6-1.5 {
 
71
  rtree_strategy {SELECT * FROM t1,t2 WHERE k=+ii AND x1<10}
 
72
} {Ca}
 
73
 
 
74
do_test rtree6.2.1 {
 
75
  query_plan {SELECT * FROM t1,t2 WHERE k=+ii AND x1<10}
 
76
} [list \
 
77
  {TABLE t1 VIRTUAL TABLE INDEX 2:Ca} \
 
78
  {TABLE t2 USING PRIMARY KEY}        \
 
79
]
 
80
 
 
81
do_test rtree6.2.2 {
 
82
  query_plan {SELECT * FROM t1,t2 WHERE k=ii AND x1<10}
 
83
} [list \
 
84
  {TABLE t1 VIRTUAL TABLE INDEX 2:Ca} \
 
85
  {TABLE t2 USING PRIMARY KEY}        \
 
86
]
 
87
 
 
88
do_test rtree6.2.3 {
 
89
  query_plan {SELECT * FROM t1,t2 WHERE k=ii}
 
90
} [list \
 
91
  {TABLE t2}                          \
 
92
  {TABLE t1 VIRTUAL TABLE INDEX 1:}   \
 
93
]
 
94
 
 
95
do_test rtree6.2.4 {
 
96
  query_plan {SELECT * FROM t1,t2 WHERE v=10 and x1<10 and x2>10}
 
97
} [list \
 
98
  {TABLE t1 VIRTUAL TABLE INDEX 2:CaEb}   \
 
99
  {TABLE t2}                              \
 
100
]
 
101
 
 
102
do_test rtree6.2.5 {
 
103
  query_plan {SELECT * FROM t1,t2 WHERE k=ii AND x1<v}
 
104
} [list \
 
105
  {TABLE t2}                              \
 
106
  {TABLE t1 VIRTUAL TABLE INDEX 1:}   \
 
107
]
 
108
 
 
109
finish_test