blob: 589f518983d0b0abdf945175fb1067eecf486b3a [file] [log] [blame]
danielk19771d461462009-04-21 09:02:45 +00001# 2009 April 14
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. The
12# focus of this file is creating and dropping virtual tables.
13#
drhdda70fe2009-06-05 17:09:11 +000014# $Id: vtabD.test,v 1.3 2009/06/05 17:09:12 drh Exp $
danielk19771d461462009-04-21 09:02:45 +000015
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18
19ifcapable !vtab||!schema_pragmas { finish_test ; return }
20
21# Register the echo module
22register_echo_module [sqlite3_connection_pointer db]
23
24do_test vtabD-1.1 {
25 execsql {
26 CREATE TABLE t1(a, b);
27 CREATE INDEX i1 ON t1(a);
28 CREATE INDEX i2 ON t1(b);
29 CREATE VIRTUAL TABLE tv1 USING echo(t1);
30 }
31} {}
32do_test vtabD-1.2 {
33 execsql BEGIN
34 for {set i 0} {$i < 100000} {incr i} {
35 execsql { INSERT INTO t1 VALUES($i, $i*$i) }
36 }
37 execsql COMMIT
38} {}
39do_test vtabD-1.3 {
40 execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 4 }
41} {1 1 2 4}
42do_test vtabD-1.4 {
43 execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 1 }
44} {1 1}
45do_test vtabD-1.5 {
46 execsql { SELECT * FROM tv1 WHERE (a > 0 AND a < 5) OR (b > 15 AND b < 65) }
47} {1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64}
48
49do_test vtabD-1.6 {
50 execsql { SELECT * FROM tv1 WHERE a < 500 OR b = 810000 }
51} [execsql {
dan2f56da32012-02-13 10:00:35 +000052 SELECT * FROM t1 WHERE a < 500;
53 SELECT * FROM t1 WHERE b = 810000 AND NOT (a < 500);
danielk19771d461462009-04-21 09:02:45 +000054}]
55
56do_test vtabD-1.7 {
57 execsql { SELECT * FROM tv1 WHERE a < 90000 OR b = 8100000000 }
58} [execsql {
dan2f56da32012-02-13 10:00:35 +000059 SELECT * FROM t1 WHERE a < 90000;
60 SELECT * FROM t1 WHERE b = 8100000000 AND NOT (a < 90000);
danielk19771d461462009-04-21 09:02:45 +000061}]
62
shaneb1a82db2009-04-23 18:42:04 +000063if {[working_64bit_int]} {
danielk19771d461462009-04-21 09:02:45 +000064do_test vtabD-1.8 {
65 execsql { SELECT * FROM tv1 WHERE a = 90001 OR b = 810000 }
66} {90001 8100180001 900 810000}
shaneb1a82db2009-04-23 18:42:04 +000067}
danielk19771d461462009-04-21 09:02:45 +000068
69finish_test