aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2023-04-07 15:07:58 +0000
committerdrh <>2023-04-07 15:07:58 +0000
commit706c33d9bac7fd5d9e02ec0907b60226a250b719 (patch)
treed5e82c45014bf4808d770a6f2c3a38a839836fd2 /src
parent34ceb7e62279f2bb274e70166a4e9c56e6794853 (diff)
downloadsqlite-706c33d9bac7fd5d9e02ec0907b60226a250b719.tar.gz
sqlite-706c33d9bac7fd5d9e02ec0907b60226a250b719.zip
Tweaks to the new insertCellFast().
FossilOrigin-Name: 203a581a9177c1083e8d5b49e8ff026af33b5c5e3e144aeda126f07a3a2953bf
Diffstat (limited to 'src')
-rw-r--r--src/btree.c26
-rw-r--r--src/sqliteInt.h6
2 files changed, 16 insertions, 16 deletions
diff --git a/src/btree.c b/src/btree.c
index 60fd496b3..e0eff6d87 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 752cbbdb7..f33f6eb20 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