xref: /sqlite-3.40.0/test/types2.test (revision 80aa5453)
1a37cdde0Sdanielk1977# 2001 September 15
2a37cdde0Sdanielk1977#
3a37cdde0Sdanielk1977# The author disclaims copyright to this source code.  In place of
4a37cdde0Sdanielk1977# a legal notice, here is a blessing:
5a37cdde0Sdanielk1977#
6a37cdde0Sdanielk1977#    May you do good and not evil.
7a37cdde0Sdanielk1977#    May you find forgiveness for yourself and forgive others.
8a37cdde0Sdanielk1977#    May you share freely, never taking more than you give.
9a37cdde0Sdanielk1977#
10a37cdde0Sdanielk1977#***********************************************************************
11a37cdde0Sdanielk1977# This file implements regression tests for SQLite library. The focus
12a37cdde0Sdanielk1977# of this file is testing the interaction of manifest types, type affinity
13a37cdde0Sdanielk1977# and comparison expressions.
14a37cdde0Sdanielk1977#
15de087bd5Sdrh# $Id: types2.test,v 1.7 2007/02/23 03:00:45 drh Exp $
16a37cdde0Sdanielk1977
17a37cdde0Sdanielk1977set testdir [file dirname $argv0]
18a37cdde0Sdanielk1977source $testdir/tester.tcl
19a37cdde0Sdanielk1977
20a37cdde0Sdanielk1977# Tests in this file are organized roughly as follows:
21a37cdde0Sdanielk1977#
22a37cdde0Sdanielk1977# types2-1.*: The '=' operator in the absence of an index.
23a37cdde0Sdanielk1977# types2-2.*: The '=' operator implemented using an index.
24e014a838Sdanielk1977# types2-3.*: The '<' operator implemented using an index.
25e014a838Sdanielk1977# types2-4.*: The '>' operator in the absence of an index.
26e014a838Sdanielk1977# types2-5.*: The 'IN(x, y...)' operator in the absence of an index.
27e014a838Sdanielk1977# types2-6.*: The 'IN(x, y...)' operator with an index.
28e014a838Sdanielk1977# types2-7.*: The 'IN(SELECT...)' operator in the absence of an index.
29e014a838Sdanielk1977# types2-8.*: The 'IN(SELECT...)' operator with an index.
30a37cdde0Sdanielk1977#
31e014a838Sdanielk1977# All tests test the operators using literals and columns, but no
32e014a838Sdanielk1977# other types of expressions. All expressions except columns are
33e014a838Sdanielk1977# handled similarly in the implementation.
34a37cdde0Sdanielk1977
35a37cdde0Sdanielk1977execsql {
36a37cdde0Sdanielk1977  CREATE TABLE t1(
37a37cdde0Sdanielk1977    i1 INTEGER,
38a37cdde0Sdanielk1977    i2 INTEGER,
39a37cdde0Sdanielk1977    n1 NUMERIC,
40a37cdde0Sdanielk1977    n2 NUMERIC,
41a37cdde0Sdanielk1977    t1 TEXT,
42a37cdde0Sdanielk1977    t2 TEXT,
43e2ea40d3Sdrh    o1 BLOB,
44e2ea40d3Sdrh    o2 BLOB
45a37cdde0Sdanielk1977  );
46a37cdde0Sdanielk1977  INSERT INTO t1 VALUES(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
47a37cdde0Sdanielk1977}
48a37cdde0Sdanielk1977
49a37cdde0Sdanielk1977proc test_bool {testname vars expr res} {
50a37cdde0Sdanielk1977  if { $vars != "" } {
51a37cdde0Sdanielk1977    execsql "UPDATE t1 SET $vars"
52a37cdde0Sdanielk1977  }
53a37cdde0Sdanielk1977
54a37cdde0Sdanielk1977  foreach {t e r} [list $testname $expr $res] {}
55a37cdde0Sdanielk1977
56a37cdde0Sdanielk1977  do_test $t.1 "execsql {SELECT $e FROM t1}" $r
57a37cdde0Sdanielk1977  do_test $t.2 "execsql {SELECT 1 FROM t1 WHERE $expr}" [expr $r?"1":""]
58a37cdde0Sdanielk1977  do_test $t.3 "execsql {SELECT 1 FROM t1 WHERE NOT ($e)}" [expr $r?"":"1"]
59a37cdde0Sdanielk1977}
60a37cdde0Sdanielk1977
61e014a838Sdanielk1977# Compare literals against literals. This should always use a numeric
62e014a838Sdanielk1977# comparison.
635f6a87b3Sdrh#
645f6a87b3Sdrh# Changed by ticket #805:  Use no affinity for literal comparisons.
655f6a87b3Sdrh#
66a37cdde0Sdanielk1977test_bool types2-1.1 "" {500 = 500.0} 1
675f6a87b3Sdrhtest_bool types2-1.2 "" {'500' = 500.0} 0
685f6a87b3Sdrhtest_bool types2-1.3 "" {500 = '500.0'} 0
695f6a87b3Sdrhtest_bool types2-1.4 "" {'500' = '500.0'} 0
70a37cdde0Sdanielk1977
71a37cdde0Sdanielk1977# Compare literals against a column with TEXT affinity
72a37cdde0Sdanielk1977test_bool types2-1.5 {t1=500} {500 = t1} 1
73a37cdde0Sdanielk1977test_bool types2-1.6 {t1=500} {'500' = t1} 1
74a37cdde0Sdanielk1977test_bool types2-1.7 {t1=500} {500.0 = t1} 0
75a37cdde0Sdanielk1977test_bool types2-1.8 {t1=500} {'500.0' = t1} 0
76a37cdde0Sdanielk1977test_bool types2-1.9 {t1='500'} {500 = t1} 1
77a37cdde0Sdanielk1977test_bool types2-1.10 {t1='500'} {'500' = t1} 1
78a37cdde0Sdanielk1977test_bool types2-1.11 {t1='500'} {500.0 = t1} 0
79a37cdde0Sdanielk1977test_bool types2-1.12 {t1='500'} {'500.0' = t1} 0
80a37cdde0Sdanielk1977
81a37cdde0Sdanielk1977# Compare literals against a column with NUMERIC affinity
82a37cdde0Sdanielk1977test_bool types2-1.13 {n1=500} {500 = n1} 1
83a37cdde0Sdanielk1977test_bool types2-1.14 {n1=500} {'500' = n1} 1
84a37cdde0Sdanielk1977test_bool types2-1.15 {n1=500} {500.0 = n1} 1
85a37cdde0Sdanielk1977test_bool types2-1.16 {n1=500} {'500.0' = n1} 1
86a37cdde0Sdanielk1977test_bool types2-1.17 {n1='500'} {500 = n1} 1
87a37cdde0Sdanielk1977test_bool types2-1.18 {n1='500'} {'500' = n1} 1
88a37cdde0Sdanielk1977test_bool types2-1.19 {n1='500'} {500.0 = n1} 1
89a37cdde0Sdanielk1977test_bool types2-1.20 {n1='500'} {'500.0' = n1} 1
90a37cdde0Sdanielk1977
91a37cdde0Sdanielk1977# Compare literals against a column with affinity NONE
92a37cdde0Sdanielk1977test_bool types2-1.21 {o1=500} {500 = o1} 1
93a37cdde0Sdanielk1977test_bool types2-1.22 {o1=500} {'500' = o1} 0
94a37cdde0Sdanielk1977test_bool types2-1.23 {o1=500} {500.0 = o1} 1
95a37cdde0Sdanielk1977test_bool types2-1.24 {o1=500} {'500.0' = o1} 0
96a37cdde0Sdanielk1977test_bool types2-1.25 {o1='500'} {500 = o1} 0
97a37cdde0Sdanielk1977test_bool types2-1.26 {o1='500'} {'500' = o1} 1
98a37cdde0Sdanielk1977test_bool types2-1.27 {o1='500'} {500.0 = o1} 0
99a37cdde0Sdanielk1977test_bool types2-1.28 {o1='500'} {'500.0' = o1} 0
100a37cdde0Sdanielk1977
101a37cdde0Sdanielk1977set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']
102a37cdde0Sdanielk1977#              1  2    3    4      5  6    7    8      9  10   11   12
103a37cdde0Sdanielk1977
104a37cdde0Sdanielk1977execsql {
105e2ea40d3Sdrh  CREATE TABLE t2(i INTEGER, n NUMERIC, t TEXT, o XBLOBY);
106a37cdde0Sdanielk1977  CREATE INDEX t2i1 ON t2(i);
107a37cdde0Sdanielk1977  CREATE INDEX t2i2 ON t2(n);
108a37cdde0Sdanielk1977  CREATE INDEX t2i3 ON t2(t);
109a37cdde0Sdanielk1977  CREATE INDEX t2i4 ON t2(o);
110a37cdde0Sdanielk1977}
111a37cdde0Sdanielk1977foreach v $vals {
112a37cdde0Sdanielk1977  execsql "INSERT INTO t2 VALUES($v, $v, $v, $v);"
113a37cdde0Sdanielk1977}
114a37cdde0Sdanielk1977
115a37cdde0Sdanielk1977proc test_boolset {testname where set} {
116a37cdde0Sdanielk1977  set ::tb_sql "SELECT rowid FROM t2 WHERE $where"
117a37cdde0Sdanielk1977  do_test $testname {
118a37cdde0Sdanielk1977    lsort -integer [execsql $::tb_sql]
119a37cdde0Sdanielk1977  } $set
120a37cdde0Sdanielk1977}
121a37cdde0Sdanielk1977
122a37cdde0Sdanielk1977test_boolset types2-2.1 {i = 10} {1 2 3 4}
123a37cdde0Sdanielk1977test_boolset types2-2.2 {i = 10.0} {1 2 3 4}
124a37cdde0Sdanielk1977test_boolset types2-2.3 {i = '10'} {1 2 3 4}
125a37cdde0Sdanielk1977test_boolset types2-2.4 {i = '10.0'} {1 2 3 4}
126a37cdde0Sdanielk1977
127a37cdde0Sdanielk1977test_boolset types2-2.5 {n = 20} {5 6 7 8}
128a37cdde0Sdanielk1977test_boolset types2-2.6 {n = 20.0} {5 6 7 8}
129a37cdde0Sdanielk1977test_boolset types2-2.7 {n = '20'} {5 6 7 8}
130a37cdde0Sdanielk1977test_boolset types2-2.8 {n = '20.0'} {5 6 7 8}
131a37cdde0Sdanielk1977
132a37cdde0Sdanielk1977test_boolset types2-2.9 {t = 20} {5 7}
133a37cdde0Sdanielk1977test_boolset types2-2.10 {t = 20.0} {6 8}
134a37cdde0Sdanielk1977test_boolset types2-2.11 {t = '20'} {5 7}
135a37cdde0Sdanielk1977test_boolset types2-2.12 {t = '20.0'} {6 8}
136a37cdde0Sdanielk1977
137a37cdde0Sdanielk1977test_boolset types2-2.10 {o = 30} {9 10}
138a37cdde0Sdanielk1977test_boolset types2-2.11 {o = 30.0} {9 10}
139a37cdde0Sdanielk1977test_boolset types2-2.12 {o = '30'} 11
140a37cdde0Sdanielk1977test_boolset types2-2.13 {o = '30.0'} 12
141a37cdde0Sdanielk1977
142a37cdde0Sdanielk1977test_boolset types2-3.1 {i < 20} {1 2 3 4}
143a37cdde0Sdanielk1977test_boolset types2-3.2 {i < 20.0} {1 2 3 4}
144a37cdde0Sdanielk1977test_boolset types2-3.3 {i < '20'} {1 2 3 4}
145a37cdde0Sdanielk1977test_boolset types2-3.4 {i < '20.0'} {1 2 3 4}
146a37cdde0Sdanielk1977
147a37cdde0Sdanielk1977test_boolset types2-3.1 {n < 20} {1 2 3 4}
148a37cdde0Sdanielk1977test_boolset types2-3.2 {n < 20.0} {1 2 3 4}
149a37cdde0Sdanielk1977test_boolset types2-3.3 {n < '20'} {1 2 3 4}
150a37cdde0Sdanielk1977test_boolset types2-3.4 {n < '20.0'} {1 2 3 4}
151a37cdde0Sdanielk1977
152a37cdde0Sdanielk1977test_boolset types2-3.1 {t < 20} {1 2 3 4}
153a37cdde0Sdanielk1977test_boolset types2-3.2 {t < 20.0} {1 2 3 4 5 7}
154a37cdde0Sdanielk1977test_boolset types2-3.3 {t < '20'} {1 2 3 4}
155a37cdde0Sdanielk1977test_boolset types2-3.4 {t < '20.0'} {1 2 3 4 5 7}
156a37cdde0Sdanielk1977
157a37cdde0Sdanielk1977test_boolset types2-3.1 {o < 20} {1 2}
158a37cdde0Sdanielk1977test_boolset types2-3.2 {o < 20.0} {1 2}
159a37cdde0Sdanielk1977test_boolset types2-3.3 {o < '20'} {1 2 3 4 5 6 9 10}
160a37cdde0Sdanielk1977test_boolset types2-3.3 {o < '20.0'} {1 2 3 4 5 6 7 9 10}
161a37cdde0Sdanielk1977
162e014a838Sdanielk1977# Compare literals against literals (always a numeric comparison).
1635f6a87b3Sdrh# Change (by ticket #805):  No affinity in comparisons
164a37cdde0Sdanielk1977test_bool types2-4.1 "" {500 > 60.0} 1
165a37cdde0Sdanielk1977test_bool types2-4.2 "" {'500' > 60.0} 1
1665f6a87b3Sdrhtest_bool types2-4.3 "" {500 > '60.0'} 0
1675f6a87b3Sdrhtest_bool types2-4.4 "" {'500' > '60.0'} 0
168a37cdde0Sdanielk1977
169a37cdde0Sdanielk1977# Compare literals against a column with TEXT affinity
170a37cdde0Sdanielk1977test_bool types2-4.5 {t1=500.0} {t1 > 500} 1
171a37cdde0Sdanielk1977test_bool types2-4.6 {t1=500.0} {t1 > '500' } 1
172a37cdde0Sdanielk1977test_bool types2-4.7 {t1=500.0} {t1 > 500.0 } 0
173a37cdde0Sdanielk1977test_bool types2-4.8 {t1=500.0} {t1 > '500.0' } 0
174a37cdde0Sdanielk1977test_bool types2-4.9 {t1='500.0'} {t1 > 500 } 1
175a37cdde0Sdanielk1977test_bool types2-4.10 {t1='500.0'} {t1 > '500' } 1
176a37cdde0Sdanielk1977test_bool types2-4.11 {t1='500.0'} {t1 > 500.0 } 0
177a37cdde0Sdanielk1977test_bool types2-4.12 {t1='500.0'} {t1 > '500.0' } 0
178a37cdde0Sdanielk1977
179a37cdde0Sdanielk1977# Compare literals against a column with NUMERIC affinity
180a37cdde0Sdanielk1977test_bool types2-4.13 {n1=400} {500 > n1} 1
181a37cdde0Sdanielk1977test_bool types2-4.14 {n1=400} {'500' > n1} 1
182a37cdde0Sdanielk1977test_bool types2-4.15 {n1=400} {500.0 > n1} 1
183a37cdde0Sdanielk1977test_bool types2-4.16 {n1=400} {'500.0' > n1} 1
184a37cdde0Sdanielk1977test_bool types2-4.17 {n1='400'} {500 > n1} 1
185a37cdde0Sdanielk1977test_bool types2-4.18 {n1='400'} {'500' > n1} 1
186a37cdde0Sdanielk1977test_bool types2-4.19 {n1='400'} {500.0 > n1} 1
187a37cdde0Sdanielk1977test_bool types2-4.20 {n1='400'} {'500.0' > n1} 1
188a37cdde0Sdanielk1977
189a37cdde0Sdanielk1977# Compare literals against a column with affinity NONE
190a37cdde0Sdanielk1977test_bool types2-4.21 {o1=500} {500 > o1} 0
191a37cdde0Sdanielk1977test_bool types2-4.22 {o1=500} {'500' > o1} 1
192a37cdde0Sdanielk1977test_bool types2-4.23 {o1=500} {500.0 > o1} 0
193a37cdde0Sdanielk1977test_bool types2-4.24 {o1=500} {'500.0' > o1} 1
194a37cdde0Sdanielk1977test_bool types2-4.25 {o1='500'} {500 > o1} 0
195a37cdde0Sdanielk1977test_bool types2-4.26 {o1='500'} {'500' > o1} 0
196a37cdde0Sdanielk1977test_bool types2-4.27 {o1='500'} {500.0 > o1} 0
197a37cdde0Sdanielk1977test_bool types2-4.28 {o1='500'} {'500.0' > o1} 1
198a37cdde0Sdanielk1977
1993e8c37e7Sdanielk1977ifcapable subquery {
200e014a838Sdanielk1977  # types2-5.* - The 'IN (x, y....)' operator with no index.
201e014a838Sdanielk1977  #
2028159a35fSdrh  # Compare literals against literals (no affinity applied)
203e014a838Sdanielk1977  test_bool types2-5.1 {} {(NULL IN ('10.0', 20)) ISNULL} 1
2048159a35fSdrh  test_bool types2-5.2 {} {10 IN ('10.0', 20)} 0
2058159a35fSdrh  test_bool types2-5.3 {} {'10' IN ('10.0', 20)} 0
206e014a838Sdanielk1977  test_bool types2-5.4 {} {10 IN (10.0, 20)} 1
207de087bd5Sdrh  test_bool types2-5.5 {} {'10.0' IN (10, 20)} 0
208e014a838Sdanielk1977
209e014a838Sdanielk1977  # Compare literals against a column with TEXT affinity
210e014a838Sdanielk1977  test_bool types2-5.6 {t1='10.0'} {t1 IN (10.0, 20)} 1
211e014a838Sdanielk1977  test_bool types2-5.7 {t1='10.0'} {t1 IN (10, 20)} 0
212e014a838Sdanielk1977  test_bool types2-5.8 {t1='10'} {t1 IN (10.0, 20)} 0
213e014a838Sdanielk1977  test_bool types2-5.9 {t1='10'} {t1 IN (20, '10.0')} 0
214e014a838Sdanielk1977  test_bool types2-5.10 {t1=10} {t1 IN (20, '10')} 1
215e014a838Sdanielk1977
216e014a838Sdanielk1977  # Compare literals against a column with NUMERIC affinity
217e014a838Sdanielk1977  test_bool types2-5.11 {n1='10.0'} {n1 IN (10.0, 20)} 1
218e014a838Sdanielk1977  test_bool types2-5.12 {n1='10.0'} {n1 IN (10, 20)} 1
219e014a838Sdanielk1977  test_bool types2-5.13 {n1='10'} {n1 IN (10.0, 20)} 1
220e014a838Sdanielk1977  test_bool types2-5.14 {n1='10'} {n1 IN (20, '10.0')} 1
221e014a838Sdanielk1977  test_bool types2-5.15 {n1=10} {n1 IN (20, '10')} 1
222e014a838Sdanielk1977
223e014a838Sdanielk1977  # Compare literals against a column with affinity NONE
224e014a838Sdanielk1977  test_bool types2-5.16 {o1='10.0'} {o1 IN (10.0, 20)} 0
225e014a838Sdanielk1977  test_bool types2-5.17 {o1='10.0'} {o1 IN (10, 20)} 0
226e014a838Sdanielk1977  test_bool types2-5.18 {o1='10'} {o1 IN (10.0, 20)} 0
227e014a838Sdanielk1977  test_bool types2-5.19 {o1='10'} {o1 IN (20, '10.0')} 0
228e014a838Sdanielk1977  test_bool types2-5.20 {o1=10} {o1 IN (20, '10')} 0
229e014a838Sdanielk1977  test_bool types2-5.21 {o1='10.0'} {o1 IN (10, 20, '10.0')} 1
230e014a838Sdanielk1977  test_bool types2-5.22 {o1='10'} {o1 IN (10.0, 20, '10')} 1
231e014a838Sdanielk1977  test_bool types2-5.23 {o1=10} {n1 IN (20, '10', 10)} 1
232de087bd5Sdrh
233de087bd5Sdrh  # Ticket #2248:  Comparisons of strings literals that look like
234de087bd5Sdrh  # numbers.
235de087bd5Sdrh  test_bool types2-5.24 {} {'1' IN ('1')} 1
236de087bd5Sdrh  test_bool types2-5.25 {} {'2' IN (2)} 0
237de087bd5Sdrh  test_bool types2-5.26 {} {3 IN ('3')} 0
238de087bd5Sdrh  test_bool types2-5.27 {} {4 IN (4)} 1
239de087bd5Sdrh
240de087bd5Sdrh  # The affinity of columns on the right side of IN(...) is ignored.
241de087bd5Sdrh  # All values in the expression list are treated as ordinary expressions,
242de087bd5Sdrh  # even if they are columns with affinity.
243de087bd5Sdrh  test_bool types2-5.30 {t1='10'} {10 IN (5,t1,'abc')} 0
244de087bd5Sdrh  test_bool types2-5.31 {t1='10'} {10 IN ('abc',t1,5)} 0
245de087bd5Sdrh  test_bool types2-5.32 {t1='010'} {10 IN (5,t1,'abc')} 0
246de087bd5Sdrh  test_bool types2-5.33 {t1='010'} {10 IN ('abc',t1,5)} 0
247de087bd5Sdrh  test_bool types2-5.34 {t1='10'} {'10' IN (5,t1,'abc')} 1
248de087bd5Sdrh  test_bool types2-5.35 {t1='10'} {'10' IN ('abc',t1,5)} 1
249de087bd5Sdrh  test_bool types2-5.36 {t1='010'} {'10' IN (5,t1,'abc')} 0
250de087bd5Sdrh  test_bool types2-5.37 {t1='010'} {'10' IN ('abc',t1,5)} 0
251de087bd5Sdrh
252de087bd5Sdrh  # Columns on both the left and right of IN(...).  Only the column
253de087bd5Sdrh  # on the left matters.  The all values on the right are treated like
254de087bd5Sdrh  # expressions.
255de087bd5Sdrh  test_bool types2-5.40 {t1='10',n1=10} {t1 IN (5,n1,11)} 1
256de087bd5Sdrh  test_bool types2-5.41 {t1='010',n1=10} {t1 IN (5,n1,11)} 0
257de087bd5Sdrh  test_bool types2-5.42 {t1='10',n1=10} {n1 IN (5,t1,11)} 1
258de087bd5Sdrh  test_bool types2-5.43 {t1='010',n1=10} {n1 IN (5,t1,11)} 1
2593e8c37e7Sdanielk1977}
260e014a838Sdanielk1977
261e014a838Sdanielk1977# Tests named types2-6.* use the same infrastructure as the types2-2.*
262e014a838Sdanielk1977# tests. The contents of the vals array is repeated here for easy
263e014a838Sdanielk1977# reference.
264e014a838Sdanielk1977#
265e014a838Sdanielk1977# set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']
266e014a838Sdanielk1977#                1  2    3    4      5  6    7    8      9  10   11   12
267e014a838Sdanielk1977
2683e8c37e7Sdanielk1977ifcapable subquery {
269e014a838Sdanielk1977  test_boolset types2-6.1 {o IN ('10', 30)} {3 9 10}
270e014a838Sdanielk1977  test_boolset types2-6.2 {o IN (20.0, 30.0)} {5 6 9 10}
271e014a838Sdanielk1977  test_boolset types2-6.3 {t IN ('10', 30)} {1 3 9 11}
272e014a838Sdanielk1977  test_boolset types2-6.4 {t IN (20.0, 30.0)} {6 8 10 12}
273e014a838Sdanielk1977  test_boolset types2-6.5 {n IN ('10', 30)} {1 2 3 4 9 10 11 12}
274e014a838Sdanielk1977  test_boolset types2-6.6 {n IN (20.0, 30.0)} {5 6 7 8 9 10 11 12}
275e014a838Sdanielk1977  test_boolset types2-6.7 {i IN ('10', 30)} {1 2 3 4 9 10 11 12}
276e014a838Sdanielk1977  test_boolset types2-6.8 {i IN (20.0, 30.0)} {5 6 7 8 9 10 11 12}
277e014a838Sdanielk1977
278e014a838Sdanielk1977  # Also test than IN(x, y, z) works on a rowid:
279e014a838Sdanielk1977  test_boolset types2-6.9 {rowid IN (1, 6, 10)} {1 6 10}
2803e8c37e7Sdanielk1977}
281e014a838Sdanielk1977
282e014a838Sdanielk1977# Tests types2-7.* concentrate on expressions of the form
283e014a838Sdanielk1977# "x IN (SELECT...)" with no index.
284e014a838Sdanielk1977execsql {
285e2ea40d3Sdrh  CREATE TABLE t3(i INTEGER, n NUMERIC, t TEXT, o BLOB);
286e014a838Sdanielk1977  INSERT INTO t3 VALUES(1, 1, 1, 1);
287e014a838Sdanielk1977  INSERT INTO t3 VALUES(2, 2, 2, 2);
288e014a838Sdanielk1977  INSERT INTO t3 VALUES(3, 3, 3, 3);
289e014a838Sdanielk1977  INSERT INTO t3 VALUES('1', '1', '1', '1');
290e014a838Sdanielk1977  INSERT INTO t3 VALUES('1.0', '1.0', '1.0', '1.0');
291e014a838Sdanielk1977}
292e014a838Sdanielk1977
2933e8c37e7Sdanielk1977ifcapable subquery {
294e014a838Sdanielk1977  test_bool types2-7.1 {i1=1} {i1 IN (SELECT i FROM t3)} 1
295e014a838Sdanielk1977  test_bool types2-7.2 {i1='2.0'} {i1 IN (SELECT i FROM t3)} 1
296e014a838Sdanielk1977  test_bool types2-7.3 {i1='2.0'} {i1 IN (SELECT n FROM t3)} 1
297e014a838Sdanielk1977  test_bool types2-7.4 {i1='2.0'} {i1 IN (SELECT t FROM t3)} 1
298e014a838Sdanielk1977  test_bool types2-7.5 {i1='2.0'} {i1 IN (SELECT o FROM t3)} 1
299e014a838Sdanielk1977
300e014a838Sdanielk1977  test_bool types2-7.6 {n1=1} {n1 IN (SELECT n FROM t3)} 1
301e014a838Sdanielk1977  test_bool types2-7.7 {n1='2.0'} {n1 IN (SELECT i FROM t3)} 1
302e014a838Sdanielk1977  test_bool types2-7.8 {n1='2.0'} {n1 IN (SELECT n FROM t3)} 1
303e014a838Sdanielk1977  test_bool types2-7.9 {n1='2.0'} {n1 IN (SELECT t FROM t3)} 1
304e014a838Sdanielk1977  test_bool types2-7.10 {n1='2.0'} {n1 IN (SELECT o FROM t3)} 1
305e014a838Sdanielk1977
306e014a838Sdanielk1977  test_bool types2-7.6 {t1=1} {t1 IN (SELECT t FROM t3)} 1
307e014a838Sdanielk1977  test_bool types2-7.7 {t1='2.0'} {t1 IN (SELECT t FROM t3)} 0
308e014a838Sdanielk1977  test_bool types2-7.8 {t1='2.0'} {t1 IN (SELECT n FROM t3)} 1
309e014a838Sdanielk1977  test_bool types2-7.9 {t1='2.0'} {t1 IN (SELECT i FROM t3)} 1
310e014a838Sdanielk1977  test_bool types2-7.10 {t1='2.0'} {t1 IN (SELECT o FROM t3)} 0
311e014a838Sdanielk1977  test_bool types2-7.11 {t1='1.0'} {t1 IN (SELECT t FROM t3)} 1
312e014a838Sdanielk1977  test_bool types2-7.12 {t1='1.0'} {t1 IN (SELECT o FROM t3)} 1
313e014a838Sdanielk1977
314e014a838Sdanielk1977  test_bool types2-7.13 {o1=2} {o1 IN (SELECT o FROM t3)} 1
315e014a838Sdanielk1977  test_bool types2-7.14 {o1='2'} {o1 IN (SELECT o FROM t3)} 0
316e014a838Sdanielk1977  test_bool types2-7.15 {o1='2'} {o1 IN (SELECT o||'' FROM t3)} 1
3173e8c37e7Sdanielk1977}
318e014a838Sdanielk1977
319e014a838Sdanielk1977# set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']
320e014a838Sdanielk1977#                1  2    3    4      5  6    7    8      9  10   11   12
321e014a838Sdanielk1977execsql {
322e2ea40d3Sdrh  CREATE TABLE t4(i INTEGER, n NUMERIC, t VARCHAR(20), o LARGE BLOB);
323e014a838Sdanielk1977  INSERT INTO t4 VALUES(10, 20, 20, 30);
324e014a838Sdanielk1977}
3253e8c37e7Sdanielk1977ifcapable subquery {
326e014a838Sdanielk1977  test_boolset types2-8.1 {i IN (SELECT i FROM t4)} {1 2 3 4}
327e014a838Sdanielk1977  test_boolset types2-8.2 {n IN (SELECT i FROM t4)} {1 2 3 4}
328e014a838Sdanielk1977  test_boolset types2-8.3 {t IN (SELECT i FROM t4)} {1 2 3 4}
329e014a838Sdanielk1977  test_boolset types2-8.4 {o IN (SELECT i FROM t4)} {1 2 3 4}
330e014a838Sdanielk1977  test_boolset types2-8.5 {i IN (SELECT t FROM t4)} {5 6 7 8}
331e014a838Sdanielk1977  test_boolset types2-8.6 {n IN (SELECT t FROM t4)} {5 6 7 8}
332e014a838Sdanielk1977  test_boolset types2-8.7 {t IN (SELECT t FROM t4)} {5 7}
333e014a838Sdanielk1977  test_boolset types2-8.8 {o IN (SELECT t FROM t4)} {7}
334e014a838Sdanielk1977  test_boolset types2-8.9 {i IN (SELECT o FROM t4)} {9 10 11 12}
335e014a838Sdanielk1977  test_boolset types2-8.6 {n IN (SELECT o FROM t4)} {9 10 11 12}
336*80aa5453Sdan  test_boolset types2-8.7 {t IN (SELECT o FROM t4)} {}
337e014a838Sdanielk1977  test_boolset types2-8.8 {o IN (SELECT o FROM t4)} {9 10}
3383e8c37e7Sdanielk1977}
339e014a838Sdanielk1977
340a37cdde0Sdanielk1977finish_test
341