mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
The original column-cache implementation from check-in [ab1edcc7fedcf279]
(merged to trunk at [771fe35074b50b8d]) is unsound. This check-in fixes the issue. Had to give back a little performance, the optimization is still a overall win. FossilOrigin-Name: ec95e970fb737adf0fab3cb4363040b036949e5eb966fc2d030a20f95e2bde60
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Add\sbit\sto\ssqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS)\sthat\swill\ndisable\sthe\sone-pass\soptimizating\sin\sDELETE\sand\sUPDATE.
|
||||
D 2023-07-31T17:39:36.821
|
||||
C The\soriginal\scolumn-cache\simplementation\sfrom\scheck-in\s[ab1edcc7fedcf279]\n(merged\sto\strunk\sat\s[771fe35074b50b8d])\sis\sunsound.\s\sThis\scheck-in\sfixes\nthe\sissue.\s\sHad\sto\sgive\sback\sa\slittle\sperformance,\sthe\soptimization\sis\sstill\na\soverall\swin.
|
||||
D 2023-07-31T20:02:11.619
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -713,9 +713,9 @@ F src/upsert.c 5303dc6c518fa7d4b280ec65170f465c7a70b7ac2b22491598f6d0b4875b3145
|
||||
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
|
||||
F src/util.c c2aa170f2eb429235b1dddce8952770787ffa5124dc89d405bfbe8ebad8e7ebd
|
||||
F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104
|
||||
F src/vdbe.c cd0396758da6a95e6c4e3bec7c3d6e767c3b39930c295c2425f83bb086cdc6ba
|
||||
F src/vdbe.c 49b0c386511cb0261dc92e3583b0d08c5c450ab404f0e139378d10661a19aa5f
|
||||
F src/vdbe.h 41485521f68e9437fdb7ec4a90f9d86ab294e9bb8281e33b235915e29122cfc0
|
||||
F src/vdbeInt.h cd829ff67fc18aff2476fe3209262ba8671cb43d51cb6913de4a670e37d2fbe3
|
||||
F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c
|
||||
F src/vdbeapi.c f37822f215740ede2a8fcae99bc13f2cc3a72dd0e1d22b81b9298c5ca67dbc38
|
||||
F src/vdbeaux.c a586f445945eef6ad1fcd7c94f700faa1baea93c0dbd446291c7cf65966c8470
|
||||
F src/vdbeblob.c 2516697b3ee8154eb8915f29466fb5d4f1ae39ee8b755ea909cefaf57ec5e2ce
|
||||
@@ -2049,8 +2049,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 4a8a17498ecaccca5e5aab65d4596cbca9799547f50683237d08c1fa3556f1cf
|
||||
R ef0070662a249066ae6d16c0760a2f90
|
||||
P 22f6dd5cd32ed9e7b932fdba98aa8652fde999df79f4995d3d8ac1acf430cf53
|
||||
R 15ab2c7da6a67c12e2ba41a7336b6a4c
|
||||
U drh
|
||||
Z 540a4a2640cda7628ceedc92fe19bc74
|
||||
Z 46639d6bc060420caa2ca32405ae95c8
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@@ -1 +1 @@
|
||||
22f6dd5cd32ed9e7b932fdba98aa8652fde999df79f4995d3d8ac1acf430cf53
|
||||
ec95e970fb737adf0fab3cb4363040b036949e5eb966fc2d030a20f95e2bde60
|
14
src/vdbe.c
14
src/vdbe.c
@@ -708,6 +708,8 @@ static SQLITE_NOINLINE int vdbeColumnFromOverflow(
|
||||
int iCol, /* The column to read */
|
||||
int t, /* The serial-type code for the column value */
|
||||
i64 iOffset, /* Offset to the start of the content value */
|
||||
u32 cacheStatus, /* Current Vdbe.cacheCtr value */
|
||||
u32 colCacheCtr, /* Current value of the column cache counter */
|
||||
Mem *pDest /* Store the value into this register. */
|
||||
){
|
||||
int rc;
|
||||
@@ -733,6 +735,8 @@ static SQLITE_NOINLINE int vdbeColumnFromOverflow(
|
||||
pCache = pC->pCache;
|
||||
if( pCache->pCValue==0
|
||||
|| pCache->iCol!=iCol
|
||||
|| pCache->cacheStatus!=cacheStatus
|
||||
|| pCache->colCacheCtr!=colCacheCtr
|
||||
|| pCache->iOffset!=sqlite3BtreeOffset(pC->uc.pCursor)
|
||||
){
|
||||
if( pCache->pCValue ) sqlite3RCStrUnref(pCache->pCValue);
|
||||
@@ -744,6 +748,8 @@ static SQLITE_NOINLINE int vdbeColumnFromOverflow(
|
||||
pBuf[len+1] = 0;
|
||||
pBuf[len+2] = 0;
|
||||
pCache->iCol = iCol;
|
||||
pCache->cacheStatus = cacheStatus;
|
||||
pCache->colCacheCtr = colCacheCtr;
|
||||
pCache->iOffset = sqlite3BtreeOffset(pC->uc.pCursor);
|
||||
}else{
|
||||
pBuf = pCache->pCValue;
|
||||
@@ -814,6 +820,7 @@ int sqlite3VdbeExec(
|
||||
Mem *pIn2 = 0; /* 2nd input operand */
|
||||
Mem *pIn3 = 0; /* 3rd input operand */
|
||||
Mem *pOut = 0; /* Output operand */
|
||||
u32 colCacheCtr = 0; /* Column cache counter */
|
||||
#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE)
|
||||
u64 *pnCycle = 0;
|
||||
int bStmtScanStatus = IS_STMT_SCANSTATUS(db)!=0;
|
||||
@@ -3162,7 +3169,8 @@ op_column_restart:
|
||||
*/
|
||||
sqlite3VdbeSerialGet((u8*)sqlite3CtypeMap, t, pDest);
|
||||
}else{
|
||||
rc = vdbeColumnFromOverflow(pC, p2, t, aOffset[p2], pDest);
|
||||
rc = vdbeColumnFromOverflow(pC, p2, t, aOffset[p2],
|
||||
p->cacheCtr, colCacheCtr, pDest);
|
||||
if( rc ){
|
||||
if( rc==SQLITE_NOMEM ) goto no_mem;
|
||||
if( rc==SQLITE_TOOBIG ) goto too_big;
|
||||
@@ -5700,6 +5708,7 @@ case OP_Insert: {
|
||||
);
|
||||
pC->deferredMoveto = 0;
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
colCacheCtr++;
|
||||
|
||||
/* Invoke the update-hook if required. */
|
||||
if( rc ) goto abort_due_to_error;
|
||||
@@ -5860,6 +5869,7 @@ case OP_Delete: {
|
||||
|
||||
rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
colCacheCtr++;
|
||||
pC->seekResult = 0;
|
||||
if( rc ) goto abort_due_to_error;
|
||||
|
||||
@@ -6431,6 +6441,7 @@ case OP_IdxInsert: { /* in2 */
|
||||
);
|
||||
assert( pC->deferredMoveto==0 );
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
colCacheCtr++;
|
||||
if( rc) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
@@ -6506,6 +6517,7 @@ case OP_IdxDelete: {
|
||||
assert( pC->deferredMoveto==0 );
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
pC->seekResult = 0;
|
||||
colCacheCtr++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -159,6 +159,8 @@ struct VdbeTxtBlbCache {
|
||||
char *pCValue; /* A RCStr buffer to hold the value */
|
||||
i64 iOffset; /* File offset of the row being cached */
|
||||
int iCol; /* Column for which the cache is valid */
|
||||
u32 cacheStatus; /* Vdbe.cacheCtr value */
|
||||
u32 colCacheCtr; /* Column cache counter */
|
||||
};
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user