Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: third_party/sqlite/src/ext/fts5/test/fts5hash.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/sqlite/src/ext/fts5/test/fts5hash.test
diff --git a/third_party/sqlite/src/ext/fts5/test/fts5hash.test b/third_party/sqlite/src/ext/fts5/test/fts5hash.test
index a4a4f283430af0ecd2f503f141bfc5997bed7b4a..f3952d615728471678f57b77a2a91ac55b863551 100644
--- a/third_party/sqlite/src/ext/fts5/test/fts5hash.test
+++ b/third_party/sqlite/src/ext/fts5/test/fts5hash.test
@@ -64,47 +64,70 @@ proc random_doc {vocab nWord} {
return $doc
}
-set vocab [build_vocab1]
-db func r random_doc
+foreach_detail_mode $testprefix {
-do_execsql_test 1.0 {
- CREATE VIRTUAL TABLE eee USING fts5(e, ee);
- BEGIN;
- WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<100)
- INSERT INTO eee SELECT r($vocab, 5), r($vocab, 7) FROM ii;
+ set vocab [build_vocab1]
+ db func r random_doc
+
+ do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE eee USING fts5(e, ee, detail=%DETAIL%);
+ BEGIN;
+ WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<100)
+ INSERT INTO eee SELECT r($vocab, 5), r($vocab, 7) FROM ii;
+ INSERT INTO eee(eee) VALUES('integrity-check');
+ COMMIT;
INSERT INTO eee(eee) VALUES('integrity-check');
- COMMIT;
- INSERT INTO eee(eee) VALUES('integrity-check');
-}
-
-set hash [sqlite3_fts5_token_hash 1024 xyz]
-set vocab [build_vocab1 -prefix xyz -hash $hash]
-lappend vocab xyz
-
-do_execsql_test 1.1 {
- CREATE VIRTUAL TABLE vocab USING fts5vocab(eee, 'row');
- BEGIN;
-}
-do_test 1.2 {
- for {set i 1} {$i <= 100} {incr i} {
- execsql { INSERT INTO eee VALUES( r($vocab, 5), r($vocab, 7) ) }
}
-} {}
-do_test 1.2 {
- db eval { SELECT term, doc FROM vocab } {
- set nRow [db one {SELECT count(*) FROM eee WHERE eee MATCH $term}]
- if {$nRow != $doc} {
- error "term=$term fts5vocab=$doc cnt=$nRow"
+ set hash [sqlite3_fts5_token_hash 1024 xyz]
+ set vocab [build_vocab1 -prefix xyz -hash $hash]
+ lappend vocab xyz
+
+ do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE vocab USING fts5vocab(eee, 'row');
+ BEGIN;
+ }
+ do_test 1.2 {
+ for {set i 1} {$i <= 100} {incr i} {
+ execsql { INSERT INTO eee VALUES( r($vocab, 5), r($vocab, 7) ) }
+ }
+ } {}
+
+ do_test 1.3 {
+ db eval { SELECT term, doc FROM vocab } {
+ set nRow [db one {SELECT count(*) FROM eee WHERE eee MATCH $term}]
+ if {$nRow != $doc} {
+ error "term=$term fts5vocab=$doc cnt=$nRow"
+ }
}
+ set {} {}
+ } {}
+
+ do_execsql_test 1.4 {
+ COMMIT;
+ INSERT INTO eee(eee) VALUES('integrity-check');
}
- set {} {}
-} {}
-do_execsql_test 1.3 {
- COMMIT;
- INSERT INTO eee(eee) VALUES('integrity-check');
-}
+ #-----------------------------------------------------------------------
+ # Add a small and very large token with the same hash value to an
+ # empty table. At one point this would provoke an asan error.
+ #
+ do_test 2.0 {
+ set big [string repeat 12345 40]
+ set hash [sqlite3_fts5_token_hash 1024 $big]
+ while {1} {
+ set small [random_token]
+ if {[sqlite3_fts5_token_hash 1024 $small]==$hash} break
+ }
+
+ execsql { CREATE VIRTUAL TABLE t2 USING fts5(x, detail=%DETAIL%) }
+breakpoint
+ execsql {
+ INSERT INTO t2 VALUES($small || ' ' || $big);
+ }
+ } {}
+
+} ;# foreach_detail_mode
finish_test
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5fuzz1.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5integrity.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698