Pull the latest trunk changes into the sessions branch.

FossilOrigin-Name: 5d95b42946b5cf0346164aebe0a8c4f37527bc31
This commit is contained in:
drh
2011-06-23 02:11:11 +00:00
11 changed files with 167 additions and 42 deletions
+107 -10
View File
@@ -22,9 +22,11 @@ ifcapable !fts3 {
return
}
do_test fts4aa-1.0 {
# This procedure fills an existing FTS3/FTS4 table with many entries.
# The table needs to have a single column (other than docid) named "words".
#
proc fts4aa_fill_table {} {
db eval {
CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
BEGIN TRANSACTION;
INSERT INTO t1(docid,words) VALUES(1001001,'In the beginning God created the heaven and the earth.');
INSERT INTO t1(docid,words) VALUES(1001002,'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.');
@@ -1561,9 +1563,41 @@ INSERT INTO t1(docid,words) VALUES(1050025,'And Joseph took an oath of the child
INSERT INTO t1(docid,words) VALUES(1050026,'So Joseph died, being an hundred and ten years old: and they embalmed him, and he was put in a coffin in Egypt.');
COMMIT;
}
}
# The following is a list of queries to perform against the above
# FTS3/FTS4 database. We will be trying these queries in various
# configurations to ensure that they always return the same answers.
#
set fts4aa_queries {
{abraham}
{the king}
{"the king"}
{abraham OR joseph}
{ab* OR jos*}
{lived t*}
{spake hebrew}
{melchizedek}
{t* melchizedek}
{melchizedek t*}
}
unset -nocomplain fts4aa_res
# Set up the baseline results
#
do_test fts4aa-1.0 {
db eval {
CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
}
fts4aa_fill_table
foreach q $::fts4aa_queries {
set r [db eval {SELECT docid FROM t1 WHERE words MATCH $q ORDER BY docid}]
set ::fts4aa_res($q) $r
}
} {}
# Legacy test cases
#
do_test fts4aa-1.1 {
db eval {
SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
@@ -1583,19 +1617,19 @@ proc mit {blob} {
}
db func mit mit
do_test fts4aa-2.1 {
do_test fts4aa-1.3 {
db eval {
SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchizedek';
}
} {1014018 {1 1 1 1 1 1533 25 20}}
do_test fts4aa-2.2 {
do_test fts4aa-1.4 {
db eval {
SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
WHERE t1 MATCH 'spake hebrew'
ORDER BY docid;
}
} {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26}}
do_test fts4aa-2.3 {
do_test fts4aa-1.5 {
db eval {
SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
WHERE t1 MATCH 'laban overtook jacob'
@@ -1603,7 +1637,7 @@ do_test fts4aa-2.3 {
}
} {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}}
do_test fts4aa-9.1 {
do_test fts4aa-1.6 {
db eval {
DELETE FROM t1 WHERE docid!=1050026;
SELECT hex(size) FROM t1_docsize;
@@ -1611,17 +1645,17 @@ do_test fts4aa-9.1 {
}
} {17 01176F}
do_test fts4aa-9.2 {
do_test fts4aa-1.7 {
db eval {
SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
}
} {}
do_test fts4aa-9.3 {
do_test fts4aa-1.8 {
db eval {
SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
}
} {}
do_test fts4aa-9.4 {
do_test fts4aa-1.9 {
# Note: Token 'in' is being deferred in the following query.
db eval {
SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
@@ -1630,4 +1664,67 @@ do_test fts4aa-9.4 {
}
} {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}}
# Should get the same search results from FTS3
#
do_test fts4aa-2.0 {
db eval {
DROP TABLE t1;
CREATE VIRTUAL TABLE t1 USING fts3(words, tokenize porter);
}
fts4aa_fill_table
} {}
unset -nocomplain ii
set ii 0
foreach {q r} [array get fts4aa_res] {
incr ii
do_test fts4aa-2.$ii {
db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
} $r
}
# Should get the same search results when the page size is very large
#
do_test fts4aa-3.0 {
db close
file delete -force test.db
sqlite3 db test.db
db eval {
PRAGMA page_size=65536;
CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
}
fts4aa_fill_table
} {}
unset -nocomplain ii
set ii 0
foreach {q r} [array get fts4aa_res] {
incr ii
do_test fts4aa-3.$ii {
db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
} $r
}
# Should get the same search results when an authorizer prevents
# all PRAGMA statements.
#
proc no_pragma_auth {code arg1 arg2 arg3 arg4} {
if {$code=="SQLITE_PRAGMA"} {return SQLITE_DENY}
return SQLITE_OK;
}
do_test fts4aa-4.0 {
db auth ::no_pragma_auth
db eval {
DROP TABLE t1;
CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
}
fts4aa_fill_table
} {}
unset -nocomplain ii
set ii 0
foreach {q r} [array get fts4aa_res] {
incr ii
do_test fts4aa-4.$ii {
db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
} $r
}
finish_test
+1
View File
@@ -51,6 +51,7 @@ proc do_re_test {tn script expression} {
# a call to getcwd() may fail if there are no free file descriptors. So
# an error may be reported for either open() or getcwd() here.
#
puts "Possible valgrind error about invalid file descriptor follows:"
do_test 1.1.1 {
set ::log [list]
list [catch {
+4 -4
View File
@@ -228,22 +228,22 @@ foreach {n tdefn rc} {
}
do_test triggerC-2.2 {
execsql {
execsql "
CREATE TABLE t22(x);
CREATE TRIGGER t22a AFTER INSERT ON t22 BEGIN
INSERT INTO t22 SELECT x + (SELECT max(x) FROM t22) FROM t22;
END;
CREATE TRIGGER t22b BEFORE INSERT ON t22 BEGIN
SELECT CASE WHEN (SELECT count(*) FROM t22) >= 100
SELECT CASE WHEN (SELECT count(*) FROM t22) >= [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]
THEN RAISE(IGNORE)
ELSE NULL END;
END;
INSERT INTO t22 VALUES(1);
SELECT count(*) FROM t22;
}
} {100}
"
} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]]
do_test triggerC-2.3 {
execsql "
+8 -1
View File
@@ -235,7 +235,14 @@ foreach {testprefix do_wal_checkpoint} {
do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}
do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
if {$tcl_platform(platform) == "windows"} {
# on unix, the size_hint is a no-op if no chunk size is set.
# the windows implementation does not have a similar check,
# and because of this, the db file size has an extra page.
do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
} {
do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
}
}
# Check that checkpoints block on the correct locks. And respond correctly