2009-04-21 13:02:45 +04:00
|
|
|
# 2009 April 17
|
|
|
|
#
|
|
|
|
# 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 code in rowhash.c.
|
|
|
|
#
|
2010-06-02 18:43:30 +04:00
|
|
|
# NB: The rowhash.c module is no longer part of the source tree. But
|
|
|
|
# we might as well keep this test.
|
|
|
|
#
|
2009-04-21 13:02:45 +04:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
|
|
|
do_test rowhash-1.1 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c);
|
|
|
|
CREATE INDEX i1 ON t1(a);
|
|
|
|
CREATE INDEX i2 ON t1(b);
|
|
|
|
CREATE INDEX i3 ON t1(c);
|
|
|
|
}
|
|
|
|
} {}
|
|
|
|
|
|
|
|
proc do_keyset_test {name lKey} {
|
|
|
|
db transaction {
|
|
|
|
execsql { DELETE FROM t1 }
|
|
|
|
foreach key $lKey {
|
2009-04-21 21:13:38 +04:00
|
|
|
execsql { INSERT OR IGNORE INTO t1 VALUES($key, 'a', 'b', 'c') }
|
2009-04-21 13:02:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
do_test $name {
|
|
|
|
lsort -integer [execsql {
|
|
|
|
SELECT id FROM t1 WHERE a = 'a' OR b = 'b' OR c = 'c';
|
|
|
|
}]
|
2009-04-28 19:48:08 +04:00
|
|
|
} [lsort -integer -unique $lKey]
|
2009-04-21 13:02:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
do_keyset_test rowhash-2.1 {1 2 3}
|
|
|
|
do_keyset_test rowhash-2.2 {0 1 2 3}
|
|
|
|
do_keyset_test rowhash-2.3 {62 125 188}
|
2009-04-23 22:42:04 +04:00
|
|
|
if {[working_64bit_int]} {
|
|
|
|
expr srand(1)
|
2010-06-02 18:43:30 +04:00
|
|
|
unset -nocomplain i L
|
2009-04-23 22:42:04 +04:00
|
|
|
for {set i 4} {$i < 10} {incr i} {
|
|
|
|
for {set j 0} {$j < 5000} {incr j} {
|
2009-05-02 16:02:01 +04:00
|
|
|
lappend L [expr int(rand()*1000000000)]
|
2009-04-23 22:42:04 +04:00
|
|
|
}
|
|
|
|
do_keyset_test rowhash-2.$i $L
|
2009-04-21 13:02:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
finish_test
|