63331b1af3
module. There are still several problems on this branch. FossilOrigin-Name: 03d94388d62fd0f1fae377d273bbd5561208adc34bd97f7ce27783b30a369fd7
92 lines
2.2 KiB
Plaintext
92 lines
2.2 KiB
Plaintext
# 2017-07-15
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#***********************************************************************
|
|
# This file implements regression tests for SQLite library. The
|
|
# focus of this file is the "swarmvtab" extension
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
set testprefix swarmvtab
|
|
|
|
ifcapable !vtab {
|
|
finish_test
|
|
return
|
|
}
|
|
|
|
load_static_extension db unionvtab
|
|
|
|
do_execsql_test 1.0 {
|
|
CREATE TABLE t0(a INTEGER PRIMARY KEY, b TEXT);
|
|
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<400)
|
|
INSERT INTO t0 SELECT i, hex(randomblob(50)) FROM s;
|
|
|
|
CREATE TABLE dir(f, t, imin, imax);
|
|
}
|
|
|
|
do_test 1.1 {
|
|
for {set i 0} {$i < 40} {incr i} {
|
|
set iMin [expr $i*10 + 1]
|
|
set iMax [expr $iMin+9]
|
|
|
|
forcedelete "test.db$i"
|
|
execsql [subst {
|
|
ATTACH 'test.db$i' AS aux;
|
|
CREATE TABLE aux.t$i (a INTEGER PRIMARY KEY, b TEXT);
|
|
INSERT INTO aux.t$i SELECT * FROM t0 WHERE a BETWEEN $iMin AND $iMax;
|
|
DETACH aux;
|
|
INSERT INTO dir VALUES('test.db$i', 't$i', $iMin, $iMax);
|
|
}]
|
|
}
|
|
|
|
execsql {
|
|
CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');
|
|
SELECT count(*) FROM pragma_database_list;
|
|
}
|
|
} {3}
|
|
|
|
do_execsql_test 1.2 {
|
|
DROP TABLE s1;
|
|
SELECT name FROM pragma_database_list;
|
|
} {main temp}
|
|
|
|
do_execsql_test 1.3 {
|
|
CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');
|
|
SELECT count(*) FROM s1 WHERE rowid<50;
|
|
} {49}
|
|
|
|
proc do_compare_test {tn where} {
|
|
set sql [subst {
|
|
SELECT (
|
|
SELECT group_concat(a || ',' || b, ',') FROM t0 WHERE $where
|
|
)==(
|
|
SELECT group_concat(a || ',' || b, ',') FROM s1 WHERE $where
|
|
)
|
|
}]
|
|
|
|
uplevel [list do_execsql_test $tn $sql 1]
|
|
}
|
|
|
|
do_compare_test 1.4 "rowid = 55"
|
|
do_compare_test 1.5 "rowid BETWEEN 20 AND 100"
|
|
do_compare_test 1.6 "rowid > 350"
|
|
do_compare_test 1.7 "rowid >= 350"
|
|
|
|
# The following both each an assert() in SQLite:
|
|
#
|
|
#do_compare_test 1.8 "rowid >= 200"
|
|
#do_test 1.x { db close } {}
|
|
#
|
|
do_execsql_test 1.x { DROP TABLE s1 }
|
|
|
|
|
|
finish_test
|
|
|