xref: /sqlite-3.40.0/test/seekscan1.test (revision 73c586bc)
1# 2022 October 7
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# This file implements regression tests for SQLite library.
12#
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16set testprefix seekscan1
17
18do_execsql_test 1.0 {
19  CREATE TABLE t1(a TEXT, b INT, c INT NOT NULL, PRIMARY KEY(a,b,c));
20  WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<1997)
21    INSERT INTO t1(a,b,c) SELECT printf('xyz%d',x/10),x/6,x FROM c;
22  INSERT INTO t1 VALUES('abc',234,6);
23  INSERT INTO t1 VALUES('abc',345,7);
24  ANALYZE;
25}
26
27do_execsql_test 1.1 {
28  SELECT a,b,c FROM t1
29  WHERE b IN (234, 345) AND c BETWEEN 6 AND 6.5 AND a='abc'
30  ORDER BY a, b;
31} {
32  abc 234 6
33}
34
35do_execsql_test 1.2 {
36  SELECT a,b,c FROM t1
37  WHERE b IN (234, 345) AND c BETWEEN 6 AND 7 AND a='abc'
38  ORDER BY a, b;
39} {
40  abc 234 6
41  abc 345 7
42}
43
44do_execsql_test 1.3 {
45  SELECT a,b,c FROM t1
46  WHERE b IN (234, 345) AND c >=6 AND a='abc'
47  ORDER BY a, b;
48} {
49  abc 234 6
50  abc 345 7
51}
52
53do_execsql_test 1.4 {
54  SELECT a,b,c FROM t1
55  WHERE b IN (234, 345) AND c<=7 AND a='abc'
56  ORDER BY a, b;
57} {
58  abc 234 6
59  abc 345 7
60}
61
62
63finish_test
64