1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Simplify the sqlite3BtreeKeyFetch() and sqlite3BtreeDataFetch() interfaces

to the storage engine.

FossilOrigin-Name: bf97598592ff60fab2a06d8b31b0201200b91684
This commit is contained in:
drh
2013-12-09 20:43:22 +00:00
parent c65faab2e1
commit 2a8d2261ed
3 changed files with 19 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
C Minor\sperformance\soptimizations\sin\spager.c. C Simplify\sthe\ssqlite3BtreeKeyFetch()\sand\ssqlite3BtreeDataFetch()\sinterfaces\nto\sthe\sstorage\sengine.
D 2013-12-09T19:25:28.392 D 2013-12-09T20:43:22.965
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,7 +166,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c 1809a7caa2504233bdddd12f5018422421789537 F src/backup.c 1809a7caa2504233bdddd12f5018422421789537
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
F src/btree.c 44a44aa21ee24763ddda98d9a41bd85498359ae2 F src/btree.c 09285d6ffe7d819b9656ea9b7ecf1ab949a926fb
F src/btree.h a61ddebc78c66795a2b93181321a116746302cc9 F src/btree.h a61ddebc78c66795a2b93181321a116746302cc9
F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0 F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0
F src/build.c 47ef8209e56d840d2b35b8a243c6ee567ad52bda F src/build.c 47ef8209e56d840d2b35b8a243c6ee567ad52bda
@@ -1146,7 +1146,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 9227ad48e1612b32a3a3e9551c49890f93abc0a7 P ba9eef5f5293633d1479e1d877bf338edb2a9471
R 2aecb7bab925cdbd0159d9e849c7e955 R 11cbe9b8d7b59f7bcb32cf4280072bce
U drh U drh
Z 455daaba8769a2d87fdc74aa6d107f2c Z c873c3f777f880d8ffd5cf3f18630860

View File

@@ -1 +1 @@
ba9eef5f5293633d1479e1d877bf338edb2a9471 bf97598592ff60fab2a06d8b31b0201200b91684

View File

@@ -4192,10 +4192,10 @@ int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
/* /*
** Return a pointer to payload information from the entry that the ** Return a pointer to payload information from the entry that the
** pCur cursor is pointing to. The pointer is to the beginning of ** pCur cursor is pointing to. The pointer is to the beginning of
** the key if skipKey==0 and it points to the beginning of data if ** the key if index btrees (pPage->intKey==0) and is the data for
** skipKey==1. The number of bytes of available key/data is written ** table btrees (pPage->intKey==1). The number of bytes of available
** into *pAmt. If *pAmt==0, then the value returned will not be ** key/data is written into *pAmt. If *pAmt==0, then the value
** a valid pointer. ** returned will not be a valid pointer.
** **
** This routine is an optimization. It is common for the entire key ** This routine is an optimization. It is common for the entire key
** and data to fit on the local page and for there to be no overflow ** and data to fit on the local page and for there to be no overflow
@@ -4208,41 +4208,21 @@ int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
** page of the database. The data might change or move the next time ** page of the database. The data might change or move the next time
** any btree routine is called. ** any btree routine is called.
*/ */
static const unsigned char *fetchPayload( static const void *fetchPayload(
BtCursor *pCur, /* Cursor pointing to entry to read from */ BtCursor *pCur, /* Cursor pointing to entry to read from */
u32 *pAmt, /* Write the number of available bytes here */ u32 *pAmt /* Write the number of available bytes here */
int skipKey /* read beginning at data if this is true */
){ ){
unsigned char *aPayload;
MemPage *pPage;
u32 nKey;
u32 nLocal;
assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]); assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
assert( pCur->eState==CURSOR_VALID ); assert( pCur->eState==CURSOR_VALID );
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
assert( cursorHoldsMutex(pCur) ); assert( cursorHoldsMutex(pCur) );
pPage = pCur->apPage[pCur->iPage]; assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
if( pCur->info.nSize==0 ){ if( pCur->info.nSize==0 ){
btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage], btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
&pCur->info); &pCur->info);
} }
aPayload = pCur->info.pCell; *pAmt = pCur->info.nLocal;
aPayload += pCur->info.nHeader; return (void*)(pCur->info.pCell + pCur->info.nHeader);
if( pPage->intKey ){
nKey = 0;
}else{
nKey = (int)pCur->info.nKey;
}
if( skipKey ){
aPayload += nKey;
nLocal = pCur->info.nLocal - nKey;
}else{
nLocal = pCur->info.nLocal;
assert( nLocal<=nKey );
}
*pAmt = nLocal;
return aPayload;
} }
@@ -4261,22 +4241,10 @@ static const unsigned char *fetchPayload(
** in the common case where no overflow pages are used. ** in the common case where no overflow pages are used.
*/ */
const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){ const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){
const void *p = 0; return fetchPayload(pCur, pAmt);
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
assert( cursorHoldsMutex(pCur) );
if( ALWAYS(pCur->eState==CURSOR_VALID) ){
p = (const void*)fetchPayload(pCur, pAmt, 0);
}
return p;
} }
const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){ const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){
const void *p = 0; return fetchPayload(pCur, pAmt);
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
assert( cursorHoldsMutex(pCur) );
if( ALWAYS(pCur->eState==CURSOR_VALID) ){
p = (const void*)fetchPayload(pCur, pAmt, 1);
}
return p;
} }