1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

In fts5, avoid starting a new merge of level L if there exists already an ongoing merge of a level less than L.

FossilOrigin-Name: 350c6e75ce3c1e81458d1baa73045df489284206e8b279ab3c2f5e3d011c262a
This commit is contained in:
dan
2024-09-30 17:28:45 +00:00
parent 54fd01c4ab
commit d5838eaa42
4 changed files with 69 additions and 12 deletions

View File

@ -4889,6 +4889,11 @@ static int fts5IndexFindDeleteMerge(Fts5Index *p, Fts5Structure *pStruct){
nBest = nPercent;
}
}
/* If pLvl is already the input level to an ongoing merge, look no
** further for a merge candidate. The caller should be allowed to
** continue merging from pLvl first. */
if( pLvl->nMerge ) break;
}
}
return iRet;
@ -8813,7 +8818,7 @@ static int fts5structConnectMethod(
/*
** We must have a single struct=? constraint that will be passed through
** into the xFilter method. If there is no valid stmt=? constraint,
** into the xFilter method. If there is no valid struct=? constraint,
** then return an SQLITE_CONSTRAINT error.
*/
static int fts5structBestIndexMethod(

View File

@ -35,8 +35,8 @@ do_execsql_test 1.01 {
}
# explain_i "UPDATE t1 SET a='a' WHERE t1.rowid=1"
breakpoint
explain_i "UPDATE t1 SET a='a' FROM t2 WHERE t1.rowid=1 AND b IS NULL"
#breakpoint
#explain_i "UPDATE t1 SET a='a' FROM t2 WHERE t1.rowid=1 AND b IS NULL"
#breakpoint
#explain_i "UPDATE t1 SET a='a' WHERE b IS NULL AND rowid=?"
@ -56,4 +56,56 @@ foreach {tn up err} {
do_catchsql_test 1.$tn $up $res($err)
}
#-------------------------------------------------------------------------
reset_db
proc random {n} { expr {abs(int(rand()*$n))} }
proc select_one {list} {
set n [llength $list]
lindex $list [random $n]
}
proc vocab {} {
list abc def ghi jkl mno pqr stu vwx yza
}
proc term {} {
select_one [vocab]
}
proc document {} {
set nTerm [expr [random 3] + 7]
set doc ""
for {set ii 0} {$ii < $nTerm} {incr ii} {
lappend doc [term]
}
set doc
}
db func document document
do_execsql_test 2.0 {
CREATE VIRTUAL TABLE ft USING fts5(a, contentless_delete=1, content='');
INSERT INTO ft(ft, rank) VALUES('pgsz', 64);
}
do_test 2.1 {
for {set ii 1} {$ii < 12} {incr ii} {
db transaction {
for {set jj 0} {$jj < 10} {incr jj} {
set doc [document]
execsql { INSERT INTO ft VALUES($doc); }
}
}
}
} {}
do_test 2.2 {
foreach r [db eval {SELECT rowid FROM ft}] {
execsql { DELETE FROM ft WHERE rowid=$r }
}
} {}
set doc [document]
do_execsql_test 2.3 {
INSERT INTO ft VALUES($doc)
}
finish_test