3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is the "swarmvtab" extension
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix swarmvtab
26 foreach name [glob -nocomplain test*.db] {
30 load_static_extension db unionvtab
31 proc create_database {filename} {
33 set num [regsub -all {[^0-9]+} $filename {}]
34 set num [string trimleft $num 0]
35 set start [expr {$num*1000}]
36 set end [expr {$start+999}]
38 CREATE TABLE t2(a INTEGER PRIMARY KEY,b);
39 WITH RECURSIVE c(x) AS (
40 VALUES($start) UNION ALL SELECT x+1 FROM c WHERE x<$end
42 INSERT INTO t2(a,b) SELECT x, printf('**%05d**',x) FROM c;
46 db func create_database create_database
48 CREATE TABLE t1(filename, tablename, istart, iend);
49 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<99)
50 INSERT INTO t1 SELECT printf('test%03d.db',x),'t2',x*1000,x*1000+999 FROM c;
51 CREATE VIRTUAL TABLE temp.v1 USING swarmvtab(
52 'SELECT * FROM t1', 'create_database'
56 SELECT b FROM v1 WHERE a=3875;
59 lsort [glob -nocomplain test?*.db]
60 } {test001.db test003.db}
62 SELECT b FROM v1 WHERE a BETWEEN 3999 AND 4000 ORDER BY a;
63 } {**03999** **04000**}
65 lsort [glob -nocomplain test?*.db]
66 } {test001.db test003.db test004.db}
68 SELECT b FROM v1 WHERE a>=99998;
69 } {**99998** **99999**}
71 lsort -dictionary [glob -nocomplain test?*.db]
72 } {test001.db test003.db test004.db test099.db}