mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Performance optimization to sqlite3_blob_read().
FossilOrigin-Name: 7459f4b7ed4007d9ec44c3bf0fcba04f5f8540a9
This commit is contained in:
27
src/btree.c
27
src/btree.c
@@ -4665,21 +4665,34 @@ int sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
||||
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
|
||||
return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
** This variant of sqlite3BtreePayload() works even if the cursor has not
|
||||
** in the CURSOR_VALID state. It is only used by the sqlite3_blob_read()
|
||||
** interface.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_INCRBLOB
|
||||
int sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
||||
static SQLITE_NOINLINE int accessPayloadChecked(
|
||||
BtCursor *pCur,
|
||||
u32 offset,
|
||||
u32 amt,
|
||||
void *pBuf
|
||||
){
|
||||
int rc;
|
||||
if ( pCur->eState==CURSOR_INVALID ){
|
||||
return SQLITE_ABORT;
|
||||
}
|
||||
assert( cursorOwnsBtShared(pCur) );
|
||||
rc = restoreCursorPosition(pCur);
|
||||
if( rc==SQLITE_OK ){
|
||||
assert( pCur->eState==CURSOR_VALID );
|
||||
assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
|
||||
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
|
||||
rc = accessPayload(pCur, offset, amt, pBuf, 0);
|
||||
return rc ? rc : accessPayload(pCur, offset, amt, pBuf, 0);
|
||||
}
|
||||
int sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
||||
if( pCur->eState==CURSOR_VALID ){
|
||||
assert( cursorOwnsBtShared(pCur) );
|
||||
return accessPayload(pCur, offset, amt, pBuf, 0);
|
||||
}else{
|
||||
return accessPayloadChecked(pCur, offset, amt, pBuf);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_INCRBLOB */
|
||||
|
||||
|
Reference in New Issue
Block a user