xref: /sqlite-3.40.0/test/seekscan1.test (revision 73c586bc)
1*73c586bcSdan# 2022 October 7
2*73c586bcSdan#
3*73c586bcSdan# The author disclaims copyright to this source code.  In place of
4*73c586bcSdan# a legal notice, here is a blessing:
5*73c586bcSdan#
6*73c586bcSdan#    May you do good and not evil.
7*73c586bcSdan#    May you find forgiveness for yourself and forgive others.
8*73c586bcSdan#    May you share freely, never taking more than you give.
9*73c586bcSdan#
10*73c586bcSdan#***********************************************************************
11*73c586bcSdan# This file implements regression tests for SQLite library.
12*73c586bcSdan#
13*73c586bcSdan
14*73c586bcSdanset testdir [file dirname $argv0]
15*73c586bcSdansource $testdir/tester.tcl
16*73c586bcSdanset testprefix seekscan1
17*73c586bcSdan
18*73c586bcSdando_execsql_test 1.0 {
19*73c586bcSdan  CREATE TABLE t1(a TEXT, b INT, c INT NOT NULL, PRIMARY KEY(a,b,c));
20*73c586bcSdan  WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<1997)
21*73c586bcSdan    INSERT INTO t1(a,b,c) SELECT printf('xyz%d',x/10),x/6,x FROM c;
22*73c586bcSdan  INSERT INTO t1 VALUES('abc',234,6);
23*73c586bcSdan  INSERT INTO t1 VALUES('abc',345,7);
24*73c586bcSdan  ANALYZE;
25*73c586bcSdan}
26*73c586bcSdan
27*73c586bcSdando_execsql_test 1.1 {
28*73c586bcSdan  SELECT a,b,c FROM t1
29*73c586bcSdan  WHERE b IN (234, 345) AND c BETWEEN 6 AND 6.5 AND a='abc'
30*73c586bcSdan  ORDER BY a, b;
31*73c586bcSdan} {
32*73c586bcSdan  abc 234 6
33*73c586bcSdan}
34*73c586bcSdan
35*73c586bcSdando_execsql_test 1.2 {
36*73c586bcSdan  SELECT a,b,c FROM t1
37*73c586bcSdan  WHERE b IN (234, 345) AND c BETWEEN 6 AND 7 AND a='abc'
38*73c586bcSdan  ORDER BY a, b;
39*73c586bcSdan} {
40*73c586bcSdan  abc 234 6
41*73c586bcSdan  abc 345 7
42*73c586bcSdan}
43*73c586bcSdan
44*73c586bcSdando_execsql_test 1.3 {
45*73c586bcSdan  SELECT a,b,c FROM t1
46*73c586bcSdan  WHERE b IN (234, 345) AND c >=6 AND a='abc'
47*73c586bcSdan  ORDER BY a, b;
48*73c586bcSdan} {
49*73c586bcSdan  abc 234 6
50*73c586bcSdan  abc 345 7
51*73c586bcSdan}
52*73c586bcSdan
53*73c586bcSdando_execsql_test 1.4 {
54*73c586bcSdan  SELECT a,b,c FROM t1
55*73c586bcSdan  WHERE b IN (234, 345) AND c<=7 AND a='abc'
56*73c586bcSdan  ORDER BY a, b;
57*73c586bcSdan} {
58*73c586bcSdan  abc 234 6
59*73c586bcSdan  abc 345 7
60*73c586bcSdan}
61*73c586bcSdan
62*73c586bcSdan
63*73c586bcSdanfinish_test
64