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

View File

@ -1,5 +1,5 @@
C Cause\sgcc\swarning\ssuppression\sin\sshell.c\sto\sbe\snice\sin\sother\sproject(s).
D 2023-02-08T14:49:52.179
C Better\sfix\sthe\sproblem\swhere\soptimizing\san\sfts5\stable\stoo\soften\scauses\sit\sto\sbecome\sunreadable\s(first\sattempt\swas\s[35bed981]).
D 2023-02-08T17:28:08.724
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -92,7 +92,7 @@ F ext/fts5/fts5_buffer.c 3001fbabb585d6de52947b44b455235072b741038391f830d6b7292
F ext/fts5/fts5_config.c 501e7d3566bc92766b0e11c0109a7c5a6146bc41144195459af5422f6c2078aa
F ext/fts5/fts5_expr.c 40174a64829d30cc86e8266306ad24980f6911edd5ca0b8c1ce7821ea1341b88
F ext/fts5/fts5_hash.c d4fb70940359f2120ccd1de7ffe64cc3efe65de9e8995b822cd536ff64c96982
F ext/fts5/fts5_index.c 8a78d6c57a1ac1b4652e88ca994ac024a8652335431e12443f241fa61c6c6049
F ext/fts5/fts5_index.c df5b29576a409f673e54b470723d817df9d5167cff208c48ab9a3773cba6fa89
F ext/fts5/fts5_main.c fe67b6fb2ef134d9dbfa3941c63f777d755b075449be1863cb913a7f8754cb69
F ext/fts5/fts5_storage.c 76c6085239eb44424004c022e9da17a5ecd5aaec859fba90ad47d3b08f4c8082
F ext/fts5/fts5_tcl.c b1445cbe69908c411df8084a10b2485500ac70a9c747cdc8cda175a3da59d8ae
@ -174,7 +174,7 @@ F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e4
F ext/fts5/test/fts5near.test 211477940142d733ac04fad97cb24095513ab2507073a99c2765c3ddd2ef58bd
F ext/fts5/test/fts5onepass.test f9b7d9b2c334900c6542a869760290e2ab5382af8fbd618834bf1fcc3e7b84da
F ext/fts5/test/fts5optimize.test 36a752d24c818792032e4ff502936fc9cc5ef938721696396fdc79214b2717f1
F ext/fts5/test/fts5optimize2.test 8ec4fccee2b33f3a7dbd431064b2e79f11e636345e3c997683eb158d6975999c
F ext/fts5/test/fts5optimize2.test c7c97693abe8a2cb572acfb1f252d78f03d3984094cfc5eb2285a76d8a702a92
F ext/fts5/test/fts5phrase.test 13e5d8e9083077b3d9c74315b3c92ec723cc6eb37c8155e0bfe1bba00559f07b
F ext/fts5/test/fts5plan.test b65cfcca9ddd6fdaa118c61e17aeec8e8433bc5b6bb307abd116514f79c49c5a
F ext/fts5/test/fts5porter.test 8d08010c28527db66bc3feebd2b8767504aaeb9b101a986342fa7833d49d0d15
@ -2045,8 +2045,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 04439f3b23b22a3c187637f286764568ee922227e3e34b2e63075876b4d1f2ac
R 5a4282edd5d64747c316d95e6189a5da
U larrybr
Z 5a1072aa059100fdccf9abcb84e30eb9
P 6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355
R da19a0cff193106684ce35fd290917f2
U dan
Z 46a321111c67d64fb04a92b485f79f0e
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355
459d986d38fc0ccbfd66801e0f22900cfed831268cf59ac8d1cd1e556f0d1441