diff options
author | drh <> | 2025-06-19 19:33:06 +0000 |
---|---|---|
committer | drh <> | 2025-06-19 19:33:06 +0000 |
commit | 397b82cf0f6ff1f701f65010128cbce9d87ce3e7 (patch) | |
tree | 982f2fb6689a33ea5c48b20df020dd4f450924fa /src | |
parent | 92d1bec5841cf12740d1976f870912dfea8b1eb9 (diff) | |
download | sqlite-397b82cf0f6ff1f701f65010128cbce9d87ce3e7.tar.gz sqlite-397b82cf0f6ff1f701f65010128cbce9d87ce3e7.zip |
Generalize the indexCellCompare() so that works on any index page, not just
the current page that a cursor is pointing to.
FossilOrigin-Name: b305a7f5db183d8e0e5d62ca3c9c6260ad94bb954f7342bd3caabcd8308a21f5
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/btree.c b/src/btree.c index f53060e7f..dc6220afa 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5882,8 +5882,8 @@ moveto_table_finish: } /* -** Compare the "idx"-th cell on the page the cursor pCur is currently -** pointing to to pIdxKey using xRecordCompare. Return negative or +** Compare the "idx"-th cell on the page pPage against the key +** pointing to by pIdxKey using xRecordCompare. Return negative or ** zero if the cell is less than or equal pIdxKey. Return positive ** if unknown. ** @@ -5898,12 +5898,11 @@ moveto_table_finish: ** a positive value as that will cause the optimization to be skipped. */ static int indexCellCompare( - BtCursor *pCur, + MemPage *pPage, int idx, UnpackedRecord *pIdxKey, RecordCompare xRecordCompare ){ - MemPage *pPage = pCur->pPage; int c; int nCell; /* Size of the pCell cell in bytes */ u8 *pCell = findCellPastPtr(pPage, idx); @@ -6012,14 +6011,14 @@ int sqlite3BtreeIndexMoveto( ){ int c; if( pCur->ix==pCur->pPage->nCell-1 - && (c = indexCellCompare(pCur, pCur->ix, pIdxKey, xRecordCompare))<=0 + && (c = indexCellCompare(pCur->pPage,pCur->ix,pIdxKey,xRecordCompare))<=0 && pIdxKey->errCode==SQLITE_OK ){ *pRes = c; return SQLITE_OK; /* Cursor already pointing at the correct spot */ } if( pCur->iPage>0 - && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0 + && indexCellCompare(pCur->pPage, 0, pIdxKey, xRecordCompare)<=0 && pIdxKey->errCode==SQLITE_OK ){ pCur->curFlags &= ~(BTCF_ValidOvfl|BTCF_AtLast); |