1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Better fix the problem where optimizing an fts5 table too often causes it to become unreadable (first attempt was [35bed981]).

FossilOrigin-Name: 459d986d38fc0ccbfd66801e0f22900cfed831268cf59ac8d1cd1e556f0d1441
This commit is contained in:
dan
2023-02-08 17:28:08 +00:00
parent 72ce57e675
commit 0d12a79310
4 changed files with 17 additions and 15 deletions

View File

@ -4770,10 +4770,10 @@ static Fts5Structure *fts5IndexOptimizeStruct(
if( pNew ){
Fts5StructureLevel *pLvl;
nByte = nSeg * sizeof(Fts5StructureSegment);
pNew->nLevel = pStruct->nLevel+1;
pNew->nLevel = MIN(pStruct->nLevel+1, FTS5_MAX_LEVEL);
pNew->nRef = 1;
pNew->nWriteCounter = pStruct->nWriteCounter;
pLvl = &pNew->aLevel[MIN(pStruct->nLevel, FTS5_MAX_LEVEL-1)];
pLvl = &pNew->aLevel[pNew->nLevel-1];
pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);
if( pLvl->aSeg ){
int iLvl, iSeg;

View File

@ -21,13 +21,15 @@ ifcapable !fts5 {
return
}
set nLoop 2500
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE t1 USING fts5(x);
INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
}
do_test 1.1 {
for {set ii 0} {$ii < 1500} {incr ii} {
for {set ii 0} {$ii < $nLoop} {incr ii} {
execsql {
INSERT INTO t1 VALUES('abc def ghi');
INSERT INTO t1 VALUES('jkl mno pqr');
@ -38,7 +40,7 @@ do_test 1.1 {
do_execsql_test 1.2 {
SELECT count(*) FROM t1('mno')
} {1500}
} $nLoop
do_execsql_test 2.0 {
CREATE VIRTUAL TABLE t2 USING fts5(x);
@ -46,7 +48,7 @@ do_execsql_test 2.0 {
}
do_test 2.1 {
for {set ii 0} {$ii < 1500} {incr ii} {
for {set ii 0} {$ii < $nLoop} {incr ii} {
execsql {
INSERT INTO t2 VALUES('abc def ghi');
INSERT INTO t2 VALUES('jkl mno pqr');
@ -57,6 +59,6 @@ do_test 2.1 {
do_execsql_test 2.2 {
SELECT count(*) FROM t2('mno')
} {1500}
} $nLoop
finish_test