mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-24 22:22:08 +03:00
Different fix for the fts5 COMMIT-following-OOM problem first fixed by [fba3129d]. This one does not cause problems if an fts5 table is renamed and then dropped within the same transaction.
FossilOrigin-Name: d8c6b246944934a7a6e027b3f5b986fd64a19dd5c5c5175f4ea8586da59a6764
This commit is contained in:
@ -360,6 +360,7 @@ struct Fts5Index {
|
|||||||
|
|
||||||
/* Error state. */
|
/* Error state. */
|
||||||
int rc; /* Current error code */
|
int rc; /* Current error code */
|
||||||
|
int flushRc;
|
||||||
|
|
||||||
/* State used by the fts5DataXXX() functions. */
|
/* State used by the fts5DataXXX() functions. */
|
||||||
sqlite3_blob *pReader; /* RO incr-blob open on %_data table */
|
sqlite3_blob *pReader; /* RO incr-blob open on %_data table */
|
||||||
@ -4120,6 +4121,7 @@ static void fts5IndexDiscardData(Fts5Index *p){
|
|||||||
sqlite3Fts5HashClear(p->pHash);
|
sqlite3Fts5HashClear(p->pHash);
|
||||||
p->nPendingData = 0;
|
p->nPendingData = 0;
|
||||||
p->nPendingRow = 0;
|
p->nPendingRow = 0;
|
||||||
|
p->flushRc = SQLITE_OK;
|
||||||
}
|
}
|
||||||
p->nContentlessDelete = 0;
|
p->nContentlessDelete = 0;
|
||||||
}
|
}
|
||||||
@ -5701,6 +5703,10 @@ static void fts5FlushOneHash(Fts5Index *p){
|
|||||||
*/
|
*/
|
||||||
static void fts5IndexFlush(Fts5Index *p){
|
static void fts5IndexFlush(Fts5Index *p){
|
||||||
/* Unless it is empty, flush the hash table to disk */
|
/* Unless it is empty, flush the hash table to disk */
|
||||||
|
if( p->flushRc ){
|
||||||
|
p->rc = p->flushRc;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if( p->nPendingData || p->nContentlessDelete ){
|
if( p->nPendingData || p->nContentlessDelete ){
|
||||||
assert( p->pHash );
|
assert( p->pHash );
|
||||||
fts5FlushOneHash(p);
|
fts5FlushOneHash(p);
|
||||||
@ -5709,6 +5715,8 @@ static void fts5IndexFlush(Fts5Index *p){
|
|||||||
p->nPendingData = 0;
|
p->nPendingData = 0;
|
||||||
p->nPendingRow = 0;
|
p->nPendingRow = 0;
|
||||||
p->nContentlessDelete = 0;
|
p->nContentlessDelete = 0;
|
||||||
|
}else if( p->nPendingData || p->nContentlessDelete ){
|
||||||
|
p->flushRc = p->rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6888,14 +6896,16 @@ static Fts5Iter *fts5SetupTokendataIter(
|
|||||||
int iLvl, iSeg, ii;
|
int iLvl, iSeg, ii;
|
||||||
|
|
||||||
pNew = fts5MultiIterAlloc(p, pStruct->nSegment);
|
pNew = fts5MultiIterAlloc(p, pStruct->nSegment);
|
||||||
if( pNew==0 ) break;
|
|
||||||
|
|
||||||
if( pSmall ){
|
if( pSmall ){
|
||||||
fts5BufferSet(&p->rc, &bSeek, pSmall->n, pSmall->p);
|
fts5BufferSet(&p->rc, &bSeek, pSmall->n, pSmall->p);
|
||||||
fts5BufferAppendBlob(&p->rc, &bSeek, 1, (const u8*)"\0");
|
fts5BufferAppendBlob(&p->rc, &bSeek, 1, (const u8*)"\0");
|
||||||
}else{
|
}else{
|
||||||
fts5BufferSet(&p->rc, &bSeek, nToken, pToken);
|
fts5BufferSet(&p->rc, &bSeek, nToken, pToken);
|
||||||
}
|
}
|
||||||
|
if( p->rc ){
|
||||||
|
sqlite3Fts5IterClose((Fts5IndexIter*)pNew);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
pNewIter = &pNew->aSeg[0];
|
pNewIter = &pNew->aSeg[0];
|
||||||
pPrevIter = (pPrev ? &pPrev->aSeg[0] : 0);
|
pPrevIter = (pPrev ? &pPrev->aSeg[0] : 0);
|
||||||
|
@ -118,7 +118,7 @@ struct Fts5FullTable {
|
|||||||
Fts5Global *pGlobal; /* Global (connection wide) data */
|
Fts5Global *pGlobal; /* Global (connection wide) data */
|
||||||
Fts5Cursor *pSortCsr; /* Sort data from this cursor */
|
Fts5Cursor *pSortCsr; /* Sort data from this cursor */
|
||||||
int iSavepoint; /* Successful xSavepoint()+1 */
|
int iSavepoint; /* Successful xSavepoint()+1 */
|
||||||
int bInSavepoint;
|
|
||||||
#ifdef SQLITE_DEBUG
|
#ifdef SQLITE_DEBUG
|
||||||
struct Fts5TransactionState ts;
|
struct Fts5TransactionState ts;
|
||||||
#endif
|
#endif
|
||||||
@ -2667,9 +2667,7 @@ static int fts5RenameMethod(
|
|||||||
){
|
){
|
||||||
int rc;
|
int rc;
|
||||||
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
|
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
|
||||||
pTab->bInSavepoint = 1;
|
|
||||||
rc = sqlite3Fts5StorageRename(pTab->pStorage, zName);
|
rc = sqlite3Fts5StorageRename(pTab->pStorage, zName);
|
||||||
pTab->bInSavepoint = 0;
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2686,26 +2684,12 @@ int sqlite3Fts5FlushToDisk(Fts5Table *pTab){
|
|||||||
static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
|
static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
|
||||||
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
|
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
char *zSql = 0;
|
|
||||||
fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
|
fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
|
||||||
|
rc = sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);
|
||||||
if( pTab->bInSavepoint==0 ){
|
if( rc==SQLITE_OK ){
|
||||||
zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')",
|
pTab->iSavepoint = iSavepoint+1;
|
||||||
pTab->p.pConfig->zDb, pTab->p.pConfig->zName, pTab->p.pConfig->zName
|
|
||||||
);
|
|
||||||
if( zSql ){
|
|
||||||
pTab->bInSavepoint = 1;
|
|
||||||
rc = sqlite3_exec(pTab->p.pConfig->db, zSql, 0, 0, 0);
|
|
||||||
pTab->bInSavepoint = 0;
|
|
||||||
sqlite3_free(zSql);
|
|
||||||
}else{
|
|
||||||
rc = SQLITE_NOMEM;
|
|
||||||
}
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
pTab->iSavepoint = iSavepoint+1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2966,7 +2950,7 @@ static int fts5ShadowName(const char *zName){
|
|||||||
** if anything is found amiss. Return a NULL pointer if everything is
|
** if anything is found amiss. Return a NULL pointer if everything is
|
||||||
** OK.
|
** OK.
|
||||||
*/
|
*/
|
||||||
static int fts5Integrity(
|
static int fts5IntegrityMethod(
|
||||||
sqlite3_vtab *pVtab, /* the FTS5 virtual table to check */
|
sqlite3_vtab *pVtab, /* the FTS5 virtual table to check */
|
||||||
const char *zSchema, /* Name of schema in which this table lives */
|
const char *zSchema, /* Name of schema in which this table lives */
|
||||||
const char *zTabname, /* Name of the table itself */
|
const char *zTabname, /* Name of the table itself */
|
||||||
@ -3024,7 +3008,7 @@ static int fts5Init(sqlite3 *db){
|
|||||||
/* xRelease */ fts5ReleaseMethod,
|
/* xRelease */ fts5ReleaseMethod,
|
||||||
/* xRollbackTo */ fts5RollbackToMethod,
|
/* xRollbackTo */ fts5RollbackToMethod,
|
||||||
/* xShadowName */ fts5ShadowName,
|
/* xShadowName */ fts5ShadowName,
|
||||||
/* xIntegrity */ fts5Integrity
|
/* xIntegrity */ fts5IntegrityMethod
|
||||||
};
|
};
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -91,7 +91,6 @@ do_execsql_test 2.2.1 {
|
|||||||
INSERT INTO vt0(c0) VALUES ('xyz');
|
INSERT INTO vt0(c0) VALUES ('xyz');
|
||||||
}
|
}
|
||||||
|
|
||||||
breakpoint
|
|
||||||
do_execsql_test 2.2.2 {
|
do_execsql_test 2.2.2 {
|
||||||
ALTER TABLE t0 RENAME TO t1;
|
ALTER TABLE t0 RENAME TO t1;
|
||||||
}
|
}
|
||||||
@ -500,6 +499,21 @@ do_execsql_test 17.5 {
|
|||||||
SELECT c0 FROM t0 WHERE c0 GLOB '*faul*';
|
SELECT c0 FROM t0 WHERE c0 GLOB '*faul*';
|
||||||
} {assertionfaultproblem}
|
} {assertionfaultproblem}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
reset_db
|
||||||
|
do_execsql_test 18.0 {
|
||||||
|
BEGIN;
|
||||||
|
CREATE VIRTUAL TABLE t1 USING fts5(text);
|
||||||
|
ALTER TABLE t1 RENAME TO t2;
|
||||||
|
}
|
||||||
|
|
||||||
|
do_execsql_test 18.1 {
|
||||||
|
DROP TABLE t2;
|
||||||
|
}
|
||||||
|
|
||||||
|
do_execsql_test 18.2 {
|
||||||
|
COMMIT;
|
||||||
|
}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
|||||||
C Rework\sthe\sjsonEachPathLength()\sroutine\sin\sjson_tree()\sso\sthat\sit\sis\nless\ssusceptible\sto\sproblems\sdue\sto\sgoofy\sobject\slabels.
|
C Different\sfix\sfor\sthe\sfts5\sCOMMIT-following-OOM\sproblem\sfirst\sfixed\sby\s[fba3129d].\sThis\sone\sdoes\snot\scause\sproblems\sif\san\sfts5\stable\sis\srenamed\sand\sthen\sdropped\swithin\sthe\ssame\stransaction.
|
||||||
D 2023-12-07T14:09:25.017
|
D 2023-12-07T14:41:58.377
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@ -96,8 +96,8 @@ F ext/fts5/fts5_buffer.c 3001fbabb585d6de52947b44b455235072b741038391f830d6b7292
|
|||||||
F ext/fts5/fts5_config.c 8072a207034b51ae9b7694121d1b5715c794e94b275e088f70ae532378ca5cdf
|
F ext/fts5/fts5_config.c 8072a207034b51ae9b7694121d1b5715c794e94b275e088f70ae532378ca5cdf
|
||||||
F ext/fts5/fts5_expr.c b1ec526371b9ffde82341423a5b9753c42cbea629a41b69f26fa377d13b95a8e
|
F ext/fts5/fts5_expr.c b1ec526371b9ffde82341423a5b9753c42cbea629a41b69f26fa377d13b95a8e
|
||||||
F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1
|
F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1
|
||||||
F ext/fts5/fts5_index.c 111fdb22e4d78a5c3813ac2c782409b3567291a48f19ae834cd50268c8e9fafc
|
F ext/fts5/fts5_index.c 6d3571d6bcecf7bc2c09885e4ce563c9aeaec8e22551cddb025afd85a6b6130c
|
||||||
F ext/fts5/fts5_main.c fb7ec495d663f40d18e420e1986316591041a70e1e4b4696ab2a7384e4c7fd7a
|
F ext/fts5/fts5_main.c b908696c52410e8383019ac0657c8a5cd0c8f60e78edc169e9b3c4b93f24c933
|
||||||
F ext/fts5/fts5_storage.c 5d10b9bdcce5b90656cad13c7d12ad4148677d4b9e3fca0481fca56d6601426d
|
F ext/fts5/fts5_storage.c 5d10b9bdcce5b90656cad13c7d12ad4148677d4b9e3fca0481fca56d6601426d
|
||||||
F ext/fts5/fts5_tcl.c cf0fd0dbe64ec272491b749e0d594f563cda03336aeb60900129e6d18b0aefb8
|
F ext/fts5/fts5_tcl.c cf0fd0dbe64ec272491b749e0d594f563cda03336aeb60900129e6d18b0aefb8
|
||||||
F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee
|
F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee
|
||||||
@ -183,7 +183,7 @@ F ext/fts5/test/fts5limits.test 8ab67cf5d311c124b6ceb0062d0297767176df4572d955fc
|
|||||||
F ext/fts5/test/fts5matchinfo.test 10c9a6f7fe61fb132299c4183c012770b10c4d5c2f2edb6df0b6607f683d737a
|
F ext/fts5/test/fts5matchinfo.test 10c9a6f7fe61fb132299c4183c012770b10c4d5c2f2edb6df0b6607f683d737a
|
||||||
F ext/fts5/test/fts5merge.test e92a8db28b45931e7a9c7b1bbd36101692759d00274df74d83fd29d25d53b3a6
|
F ext/fts5/test/fts5merge.test e92a8db28b45931e7a9c7b1bbd36101692759d00274df74d83fd29d25d53b3a6
|
||||||
F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2
|
F ext/fts5/test/fts5merge2.test 3ebad1a59d6ad3fb66eff6523a09e95dc6367cbefb3cd73196801dea0425c8e2
|
||||||
F ext/fts5/test/fts5misc.test 5ca82f2a5ee016b0842043155d1382f98a34d0d86b2791165a44d7807f6e0f54
|
F ext/fts5/test/fts5misc.test dd97c86c9cbc3e587067e640f6ce88842cfbf5d23bb0e0fbb7f6707623b2d505
|
||||||
F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581
|
F ext/fts5/test/fts5multi.test a15bc91cdb717492e6e1b66fec1c356cb57386b980c7ba5af1915f97fe878581
|
||||||
F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45
|
F ext/fts5/test/fts5multiclient.test 5ff811c028d6108045ffef737f1e9f05028af2458e456c0937c1d1b8dea56d45
|
||||||
F ext/fts5/test/fts5near.test 211477940142d733ac04fad97cb24095513ab2507073a99c2765c3ddd2ef58bd
|
F ext/fts5/test/fts5near.test 211477940142d733ac04fad97cb24095513ab2507073a99c2765c3ddd2ef58bd
|
||||||
@ -2153,8 +2153,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 451cef8609e96dd9244818adc5c6f240544694bcb4ae620e88f90e403e59d70f
|
P 858b76a00e8ff55215f7a2e6a4cd77fc4d4f98dea7224cd90488744f5ce246a4
|
||||||
R 7ecf4ae92b8b647771c0ed38f3fc271f
|
R 80da091f0378004e59c1289240cd4ed3
|
||||||
U drh
|
U dan
|
||||||
Z 2abe6b160a42e7f20184ba1ba8e11b5c
|
Z f4bdf66e363ead249a9b82f208481974
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
858b76a00e8ff55215f7a2e6a4cd77fc4d4f98dea7224cd90488744f5ce246a4
|
d8c6b246944934a7a6e027b3f5b986fd64a19dd5c5c5175f4ea8586da59a6764
|
Reference in New Issue
Block a user