From: drh <> Date: Fri, 7 Apr 2023 15:07:58 +0000 (+0000) Subject: Tweaks to the new insertCellFast(). X-Git-Tag: version-3.42.0~167^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=706c33d9bac7fd5d9e02ec0907b60226a250b719;p=thirdparty%2Fsqlite.git Tweaks to the new insertCellFast(). FossilOrigin-Name: 203a581a9177c1083e8d5b49e8ff026af33b5c5e3e144aeda126f07a3a2953bf --- diff --git a/manifest b/manifest index 6c6258fe15..88efe08c72 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clone\sinsertCell()\sinto\sinsertCellFast()\sfor\suse\sby\ssqlite3BtreeInsert()\sfor\na\ssubstantial\sperformance\sincrease. -D 2023-04-07T14:33:33.532 +C Tweaks\sto\sthe\snew\sinsertCellFast(). +D 2023-04-07T15:07:58.639 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -564,7 +564,7 @@ F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7 F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d F src/btmutex.c 6ffb0a22c19e2f9110be0964d0731d2ef1c67b5f7fabfbaeb7b9dabc4b7740ca -F src/btree.c ba9cc15bd5c74ad9e26cd474837429c53695a86f4dd6ed1ede13102f5af1f27d +F src/btree.c 5e041121901c610debad04a39043ccc59ea1ec97ed2cc917f50f0220454baef3 F src/btree.h aa354b9bad4120af71e214666b35132712b8f2ec11869cb2315c52c81fad45cc F src/btreeInt.h a3268a60cbc91f578001f44ba40aae9c1b8aecbb0d2c095dd7fc54b0872ea4b8 F src/build.c 8357d6ca9a8c9afc297c431df28bc2af407b47f3ef2311875276c944b30c4d54 @@ -630,7 +630,7 @@ F src/shell.c.in 2140c98b8185ce5f024d706a552dd0ee861c35621dab6599a9234019348bf9d F src/sqlite.h.in 84f0e61a07292977c31f108776e5148eb1c761e7c276de2290c1511dad7c7d3a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h da473ce2b3d0ae407a6300c4a164589b9a6bfdbec9462688a8593ff16f3bb6e4 -F src/sqliteInt.h b2e1fb7dc1ae6103fcfdcd6bc47bafd1b517d180473e4f560feaae7e8a8a1455 +F src/sqliteInt.h a605bcdaf9083655e848b54d55c053000ed4ab8325cca8696c41585ba8ac05fd F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657 F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2052,8 +2052,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 8dc5292ee592f16451441e33ad0800ba10a21ecd63f1f9926d6915a59a1552d3 -R 4cd0c4e73a1dfc42c4a1aab1944d088a +P f225afd90c8e65661d8b855050f0ee1a8fe4c0f3bcec824aa5a66d906f3c7119 +R 68ed98237478b3a68b6eb72f11a471eb U drh -Z 8d2b56b02beff3e147538fb72d3dce05 +Z 69bb1d90ac950c6d096f89e22cd7c390 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6aa70bab6f..bba05ea546 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f225afd90c8e65661d8b855050f0ee1a8fe4c0f3bcec824aa5a66d906f3c7119 \ No newline at end of file +203a581a9177c1083e8d5b49e8ff026af33b5c5e3e144aeda126f07a3a2953bf \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 60fd496b34..e0eff6d87f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7126,14 +7126,13 @@ static int insertCell( assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB ); assert( pPage->nFree>=0 ); + assert( iChild>0 ); if( pPage->nOverflow || sz+2>pPage->nFree ){ if( pTemp ){ memcpy(pTemp, pCell, sz); pCell = pTemp; } - if( iChild ){ - put4byte(pCell, iChild); - } + put4byte(pCell, iChild); j = pPage->nOverflow++; /* Comparison against ArraySize-1 since we hold back one extra slot ** as a contingency. In other words, never need more than 3 overflow @@ -7165,17 +7164,13 @@ static int insertCell( assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB ); assert( idx+sz <= (int)pPage->pBt->usableSize ); pPage->nFree -= (u16)(2 + sz); - if( iChild ){ - /* In a corrupt database where an entry in the cell index section of - ** a btree page has a value of 3 or less, the pCell value might point - ** as many as 4 bytes in front of the start of the aData buffer for - ** the source page. Make sure this does not cause problems by not - ** reading the first 4 bytes */ - memcpy(&data[idx+4], pCell+4, sz-4); - put4byte(&data[idx], iChild); - }else{ - memcpy(&data[idx], pCell, sz); - } + /* In a corrupt database where an entry in the cell index section of + ** a btree page has a value of 3 or less, the pCell value might point + ** as many as 4 bytes in front of the start of the aData buffer for + ** the source page. Make sure this does not cause problems by not + ** reading the first 4 bytes */ + memcpy(&data[idx+4], pCell+4, sz-4); + put4byte(&data[idx], iChild); pIns = pPage->aCellIdx + i*2; memmove(pIns+2, pIns, 2*(pPage->nCell - i)); put2byte(pIns, idx); @@ -7226,7 +7221,8 @@ static int insertCellFast( assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB ); assert( pPage->nFree>=0 ); - if( pPage->nOverflow || sz+2>pPage->nFree ){ + assert( pPage->nOverflow==0 ); + if( sz+2>pPage->nFree ){ j = pPage->nOverflow++; /* Comparison against ArraySize-1 since we hold back one extra slot ** as a contingency. In other words, never need more than 3 overflow diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 752cbbdb78..f33f6eb20f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -281,7 +281,7 @@ #endif /* -** A macro to hint to the compiler that a function should not be +** Macros to hint to the compiler that a function should or should not be ** inlined. */ #if defined(__GNUC__) @@ -294,6 +294,10 @@ # define SQLITE_NOINLINE # define SQLITE_INLINE #endif +#if defined(SQLITE_COVERAGE_TEST) +# undef SQLITE_INLINE +# define SQLITE_INLINE +#endif /* ** Make sure that the compiler intrinsics we desire are enabled when