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 swarmvtab2
27 foreach name [glob -nocomplain test*.db] {
31 load_static_extension db unionvtab
32 proc create_database {filename} {
34 set num [regsub -all {[^0-9]+} $filename {}]
35 set num [string trimleft $num 0]
36 set start [expr {$num*1000}]
37 set end [expr {$start+999}]
39 CREATE TABLE t2(a INTEGER PRIMARY KEY,b);
40 WITH RECURSIVE c(x) AS (
41 VALUES($start) UNION ALL SELECT x+1 FROM c WHERE x<$end
43 INSERT INTO t2(a,b) SELECT x, printf('**%05d**',x) FROM c;
47 db func create_database create_database
49 CREATE TABLE t1(filename, tablename, istart, iend);
50 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<99)
51 INSERT INTO t1 SELECT printf('test%03d.db',x),'t2',x*1000,x*1000+999 FROM c;
52 CREATE VIRTUAL TABLE temp.v1 USING swarmvtab(
53 'SELECT * FROM t1', 'create_database'
57 SELECT b FROM v1 WHERE a=3875;
60 lsort [glob -nocomplain test?*.db]
61 } {test001.db test003.db}
63 SELECT b FROM v1 WHERE a BETWEEN 3999 AND 4000 ORDER BY a;
64 } {**03999** **04000**}
66 lsort [glob -nocomplain test?*.db]
67 } {test001.db test003.db test004.db}
69 SELECT b FROM v1 WHERE a>=99998;
70 } {**99998** **99999**}
72 lsort -dictionary [glob -nocomplain test?*.db]
73 } {test001.db test003.db test004.db test099.db}