interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / vtabD.test

69 lines · 1918 bytes Raw Blame History
1# 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#
14# $Id: vtabD.test,v 1.3 2009/06/05 17:09:12 drh Exp $
15
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 {
52 SELECT * FROM t1 WHERE a < 500;
53 SELECT * FROM t1 WHERE b = 810000 AND NOT (a < 500);
54}]
55
56do_test vtabD-1.7 {
57 execsql { SELECT * FROM tv1 WHERE a < 90000 OR b = 8100000000 }
58} [execsql {
59 SELECT * FROM t1 WHERE a < 90000;
60 SELECT * FROM t1 WHERE b = 8100000000 AND NOT (a < 90000);
61}]
62
63if {[working_64bit_int]} {
64do_test vtabD-1.8 {
65 execsql { SELECT * FROM tv1 WHERE a = 90001 OR b = 810000 }
66} {90001 8100180001 900 810000}
67}
68
69finish_test