mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Refactor the sqlite3BtreeKey() and sqlite3BtreeData() internal interfaces
into sqlite3BtreePayload() and sqlite3BtreePayloadChecked(), respectively. This is a continuation of the optimization started by check-in [2d831074cf]. The result is a slightly smaller and faster binary. FossilOrigin-Name: 49ebc219faea30eaa61def4a3fba2817b9c58a86
This commit is contained in:
26
manifest
26
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Small\sperformance\sincrease\sand\ssize\sreduction\sin\sthe\sOP_Column\sopcode.
|
C Refactor\sthe\ssqlite3BtreeKey()\sand\ssqlite3BtreeData()\sinternal\sinterfaces\ninto\ssqlite3BtreePayload()\sand\ssqlite3BtreePayloadChecked(),\srespectively.\nThis\sis\sa\scontinuation\sof\sthe\soptimization\sstarted\sby\scheck-in\n[2d831074cf].\s\sThe\sresult\sis\sa\sslightly\ssmaller\sand\sfaster\sbinary.
|
||||||
D 2016-11-25T17:03:03.293
|
D 2016-11-25T19:18:28.043
|
||||||
F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8
|
F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4
|
F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4
|
||||||
@@ -330,8 +330,8 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792
|
|||||||
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
|
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
|
||||||
F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63
|
F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63
|
||||||
F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73
|
F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73
|
||||||
F src/btree.c 090a13ac2a11bff2fcd30763a7347af998cf468f
|
F src/btree.c 9b30dbe2f6306c50dc5af8296e67034400de37cb
|
||||||
F src/btree.h 01ec45846fa177e929f01ee36a8e34337d653544
|
F src/btree.h 2349a588abcd7e0c04f984e15c5c777b61637583
|
||||||
F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5
|
F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5
|
||||||
F src/build.c 178f16698cbcb43402c343a9413fe22c99ffee21
|
F src/build.c 178f16698cbcb43402c343a9413fe22c99ffee21
|
||||||
F src/callback.c 2e76147783386374bf01b227f752c81ec872d730
|
F src/callback.c 2e76147783386374bf01b227f752c81ec872d730
|
||||||
@@ -454,13 +454,13 @@ F src/update.c 68714ed42a506d782a3d75ff8f09640706d6a3b2
|
|||||||
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
|
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
|
||||||
F src/util.c 3e2da6101888d073e79ecc6af5e0a2f70fa1e498
|
F src/util.c 3e2da6101888d073e79ecc6af5e0a2f70fa1e498
|
||||||
F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16
|
F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16
|
||||||
F src/vdbe.c 54a1d3e143a87ebcd355c956999b667dcfb64824
|
F src/vdbe.c e8802d83ebd04db1ff91137f26834a08a560575c
|
||||||
F src/vdbe.h c044be7050ac6bf596eecc6ab159f5dbc020a3b7
|
F src/vdbe.h c044be7050ac6bf596eecc6ab159f5dbc020a3b7
|
||||||
F src/vdbeInt.h 29b25318a0286c4b2599c0fbef6acf524398489a
|
F src/vdbeInt.h 9b498d3cb52dc2efb53571fb8ae8e14cf298ce84
|
||||||
F src/vdbeapi.c 97129bec6b1553da50d8e73f523c278bda66d9f6
|
F src/vdbeapi.c ea4e2dc2213cc6bd7bee375a29a9b51c31b93ae0
|
||||||
F src/vdbeaux.c c0adf6e1ce14e0b511fbeb71aa3ef1d603051b71
|
F src/vdbeaux.c 50a8caa4c8ce8b4c26bad807a6cae89fcc3bdb7e
|
||||||
F src/vdbeblob.c ba5b57b9fa47b320ad5c46468e77d8660c931190
|
F src/vdbeblob.c f4f98ea672b242f807c08c92c7faaa79e5091b65
|
||||||
F src/vdbemem.c fcdd73a2001a673f48a244a77b1038928ae729c9
|
F src/vdbemem.c 1af2f14ab0f7004b364933ddcfc767fb880d4742
|
||||||
F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c
|
F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c
|
||||||
F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
|
F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
|
||||||
F src/vtab.c e02cacb5c7ae742631edeb9ae9f53d399f093fd8
|
F src/vtab.c e02cacb5c7ae742631edeb9ae9f53d399f093fd8
|
||||||
@@ -1534,7 +1534,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P c53dca7fadd81ea340fef776373cbb122c9ccd46
|
P a9498407e646305e7b60115d63e85c642bbd1c3f
|
||||||
R 5cc42cc506bbe372234cb9f20b970e00
|
R 7c80cb213cf47d7b67265bccbb049e71
|
||||||
U drh
|
U drh
|
||||||
Z dac9238c0e962ec79642eb1c1f1654f2
|
Z ea86d85568a47d84eaa403d5a88154cd
|
||||||
|
@@ -1 +1 @@
|
|||||||
a9498407e646305e7b60115d63e85c642bbd1c3f
|
49ebc219faea30eaa61def4a3fba2817b9c58a86
|
35
src/btree.c
35
src/btree.c
@@ -632,7 +632,7 @@ static int saveCursorKey(BtCursor *pCur){
|
|||||||
pCur->nKey = sqlite3BtreePayloadSize(pCur);
|
pCur->nKey = sqlite3BtreePayloadSize(pCur);
|
||||||
pKey = sqlite3Malloc( pCur->nKey );
|
pKey = sqlite3Malloc( pCur->nKey );
|
||||||
if( pKey ){
|
if( pKey ){
|
||||||
rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
|
rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
pCur->pKey = pKey;
|
pCur->pKey = pKey;
|
||||||
}else{
|
}else{
|
||||||
@@ -4651,43 +4651,35 @@ static int accessPayload(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Read part of the key associated with cursor pCur. Exactly
|
** Read part of the payload for the row at which that cursor pCur is currently
|
||||||
** "amt" bytes will be transferred into pBuf[]. The transfer
|
** pointing. "amt" bytes will be transferred into pBuf[]. The transfer
|
||||||
** begins at "offset".
|
** begins at "offset".
|
||||||
**
|
**
|
||||||
** The caller must ensure that pCur is pointing to a valid row
|
** pCur can be pointing to either a table or an index b-tree.
|
||||||
** in the table.
|
** If pointing to a table btree, then the content section is read. If
|
||||||
|
** pCur is pointing to an index b-tree then the key section is read.
|
||||||
|
**
|
||||||
|
** For sqlite3BtreePayload(), the caller must ensure that pCur is pointing
|
||||||
|
** to a valid row in the table. For sqlite3BtreePayloadChecked(), the
|
||||||
|
** cursor might be invalid or might need to be restored before being read.
|
||||||
**
|
**
|
||||||
** Return SQLITE_OK on success or an error code if anything goes
|
** Return SQLITE_OK on success or an error code if anything goes
|
||||||
** wrong. An error is returned if "offset+amt" is larger than
|
** wrong. An error is returned if "offset+amt" is larger than
|
||||||
** the available payload.
|
** the available payload.
|
||||||
*/
|
*/
|
||||||
int sqlite3BtreeKey(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
int sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
||||||
assert( cursorHoldsMutex(pCur) );
|
assert( cursorHoldsMutex(pCur) );
|
||||||
assert( pCur->eState==CURSOR_VALID );
|
assert( pCur->eState==CURSOR_VALID );
|
||||||
assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
|
assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
|
||||||
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
|
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
|
||||||
return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);
|
return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** Read part of the data associated with cursor pCur. Exactly
|
|
||||||
** "amt" bytes will be transfered into pBuf[]. The transfer
|
|
||||||
** begins at "offset".
|
|
||||||
**
|
|
||||||
** Return SQLITE_OK on success or an error code if anything goes
|
|
||||||
** wrong. An error is returned if "offset+amt" is larger than
|
|
||||||
** the available payload.
|
|
||||||
*/
|
|
||||||
int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_INCRBLOB
|
#ifndef SQLITE_OMIT_INCRBLOB
|
||||||
|
int sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
||||||
|
int rc;
|
||||||
if ( pCur->eState==CURSOR_INVALID ){
|
if ( pCur->eState==CURSOR_INVALID ){
|
||||||
return SQLITE_ABORT;
|
return SQLITE_ABORT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
assert( cursorOwnsBtShared(pCur) );
|
assert( cursorOwnsBtShared(pCur) );
|
||||||
rc = restoreCursorPosition(pCur);
|
rc = restoreCursorPosition(pCur);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
@@ -4698,6 +4690,7 @@ int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
|||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
#endif /* SQLITE_OMIT_INCRBLOB */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return a pointer to payload information from the entry that the
|
** Return a pointer to payload information from the entry that the
|
||||||
|
@@ -289,15 +289,15 @@ int sqlite3BtreeNext(BtCursor*, int *pRes);
|
|||||||
int sqlite3BtreeEof(BtCursor*);
|
int sqlite3BtreeEof(BtCursor*);
|
||||||
int sqlite3BtreePrevious(BtCursor*, int *pRes);
|
int sqlite3BtreePrevious(BtCursor*, int *pRes);
|
||||||
i64 sqlite3BtreeIntegerKey(BtCursor*);
|
i64 sqlite3BtreeIntegerKey(BtCursor*);
|
||||||
int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
|
int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
|
||||||
const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
|
const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
|
||||||
u32 sqlite3BtreePayloadSize(BtCursor*);
|
u32 sqlite3BtreePayloadSize(BtCursor*);
|
||||||
int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
|
|
||||||
|
|
||||||
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
|
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
|
||||||
struct Pager *sqlite3BtreePager(Btree*);
|
struct Pager *sqlite3BtreePager(Btree*);
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_INCRBLOB
|
#ifndef SQLITE_OMIT_INCRBLOB
|
||||||
|
int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);
|
||||||
int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
|
int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
|
||||||
void sqlite3BtreeIncrblobCursor(BtCursor *);
|
void sqlite3BtreeIncrblobCursor(BtCursor *);
|
||||||
#endif
|
#endif
|
||||||
|
12
src/vdbe.c
12
src/vdbe.c
@@ -2549,8 +2549,7 @@ case OP_Column: {
|
|||||||
/* Make sure zData points to enough of the record to cover the header. */
|
/* Make sure zData points to enough of the record to cover the header. */
|
||||||
if( pC->aRow==0 ){
|
if( pC->aRow==0 ){
|
||||||
memset(&sMem, 0, sizeof(sMem));
|
memset(&sMem, 0, sizeof(sMem));
|
||||||
rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, 0, aOffset[0],
|
rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, 0, aOffset[0], &sMem);
|
||||||
!pC->isTable, &sMem);
|
|
||||||
if( rc!=SQLITE_OK ) goto abort_due_to_error;
|
if( rc!=SQLITE_OK ) goto abort_due_to_error;
|
||||||
zData = (u8*)sMem.z;
|
zData = (u8*)sMem.z;
|
||||||
}else{
|
}else{
|
||||||
@@ -2663,8 +2662,7 @@ case OP_Column: {
|
|||||||
static u8 aZero[8]; /* This is the bogus content */
|
static u8 aZero[8]; /* This is the bogus content */
|
||||||
sqlite3VdbeSerialGet(aZero, t, pDest);
|
sqlite3VdbeSerialGet(aZero, t, pDest);
|
||||||
}else{
|
}else{
|
||||||
rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len,
|
rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
|
||||||
!pC->isTable, pDest);
|
|
||||||
if( rc!=SQLITE_OK ) goto abort_due_to_error;
|
if( rc!=SQLITE_OK ) goto abort_due_to_error;
|
||||||
sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
|
sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
|
||||||
pDest->flags &= ~MEM_Ephem;
|
pDest->flags &= ~MEM_Ephem;
|
||||||
@@ -4705,11 +4703,7 @@ case OP_RowData: {
|
|||||||
}
|
}
|
||||||
pOut->n = n;
|
pOut->n = n;
|
||||||
MemSetTypeFlag(pOut, MEM_Blob);
|
MemSetTypeFlag(pOut, MEM_Blob);
|
||||||
if( pC->isTable==0 ){
|
rc = sqlite3BtreePayload(pCrsr, 0, n, pOut->z);
|
||||||
rc = sqlite3BtreeKey(pCrsr, 0, n, pOut->z);
|
|
||||||
}else{
|
|
||||||
rc = sqlite3BtreeData(pCrsr, 0, n, pOut->z);
|
|
||||||
}
|
|
||||||
if( rc ) goto abort_due_to_error;
|
if( rc ) goto abort_due_to_error;
|
||||||
pOut->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */
|
pOut->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */
|
||||||
UPDATE_MAX_BLOBSIZE(pOut);
|
UPDATE_MAX_BLOBSIZE(pOut);
|
||||||
|
@@ -487,7 +487,7 @@ void sqlite3VdbeIntegerAffinity(Mem*);
|
|||||||
int sqlite3VdbeMemRealify(Mem*);
|
int sqlite3VdbeMemRealify(Mem*);
|
||||||
int sqlite3VdbeMemNumerify(Mem*);
|
int sqlite3VdbeMemNumerify(Mem*);
|
||||||
void sqlite3VdbeMemCast(Mem*,u8,u8);
|
void sqlite3VdbeMemCast(Mem*,u8,u8);
|
||||||
int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,int,Mem*);
|
int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
|
||||||
void sqlite3VdbeMemRelease(Mem *p);
|
void sqlite3VdbeMemRelease(Mem *p);
|
||||||
int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
|
int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
|
||||||
const char *sqlite3OpcodeName(int);
|
const char *sqlite3OpcodeName(int);
|
||||||
|
@@ -1695,7 +1695,7 @@ int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
|
|||||||
nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
|
nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
|
||||||
aRec = sqlite3DbMallocRaw(db, nRec);
|
aRec = sqlite3DbMallocRaw(db, nRec);
|
||||||
if( !aRec ) goto preupdate_old_out;
|
if( !aRec ) goto preupdate_old_out;
|
||||||
rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec);
|
rc = sqlite3BtreePayload(p->pCsr->uc.pCursor, 0, nRec, aRec);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
|
p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
|
||||||
if( !p->pUnpacked ) rc = SQLITE_NOMEM;
|
if( !p->pUnpacked ) rc = SQLITE_NOMEM;
|
||||||
|
@@ -4365,7 +4365,7 @@ int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
|
|||||||
|
|
||||||
/* Read in the complete content of the index entry */
|
/* Read in the complete content of the index entry */
|
||||||
sqlite3VdbeMemInit(&m, db, 0);
|
sqlite3VdbeMemInit(&m, db, 0);
|
||||||
rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m);
|
rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);
|
||||||
if( rc ){
|
if( rc ){
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -4445,7 +4445,7 @@ int sqlite3VdbeIdxKeyCompare(
|
|||||||
return SQLITE_CORRUPT_BKPT;
|
return SQLITE_CORRUPT_BKPT;
|
||||||
}
|
}
|
||||||
sqlite3VdbeMemInit(&m, db, 0);
|
sqlite3VdbeMemInit(&m, db, 0);
|
||||||
rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m);
|
rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);
|
||||||
if( rc ){
|
if( rc ){
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@@ -440,7 +440,7 @@ static int blobReadWrite(
|
|||||||
** Read data from a blob handle.
|
** Read data from a blob handle.
|
||||||
*/
|
*/
|
||||||
int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
|
int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
|
||||||
return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
|
return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreePayloadChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -934,10 +934,9 @@ int sqlite3VdbeMemSetStr(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Move data out of a btree key or data field and into a Mem structure.
|
** Move data out of a btree key or data field and into a Mem structure.
|
||||||
** The data or key is taken from the entry that pCur is currently pointing
|
** The data is payload from the entry that pCur is currently pointing
|
||||||
** to. offset and amt determine what portion of the data or key to retrieve.
|
** to. offset and amt determine what portion of the data or key to retrieve.
|
||||||
** key is true to get the key or false to get data. The result is written
|
** The result is written into the pMem element.
|
||||||
** into the pMem element.
|
|
||||||
**
|
**
|
||||||
** The pMem object must have been initialized. This routine will use
|
** The pMem object must have been initialized. This routine will use
|
||||||
** pMem->zMalloc to hold the content from the btree, if possible. New
|
** pMem->zMalloc to hold the content from the btree, if possible. New
|
||||||
@@ -952,17 +951,12 @@ static SQLITE_NOINLINE int vdbeMemFromBtreeResize(
|
|||||||
BtCursor *pCur, /* Cursor pointing at record to retrieve. */
|
BtCursor *pCur, /* Cursor pointing at record to retrieve. */
|
||||||
u32 offset, /* Offset from the start of data to return bytes from. */
|
u32 offset, /* Offset from the start of data to return bytes from. */
|
||||||
u32 amt, /* Number of bytes to return. */
|
u32 amt, /* Number of bytes to return. */
|
||||||
int key, /* If true, retrieve from the btree key, not data. */
|
|
||||||
Mem *pMem /* OUT: Return data in this Mem structure. */
|
Mem *pMem /* OUT: Return data in this Mem structure. */
|
||||||
){
|
){
|
||||||
int rc;
|
int rc;
|
||||||
pMem->flags = MEM_Null;
|
pMem->flags = MEM_Null;
|
||||||
if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+2)) ){
|
if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+2)) ){
|
||||||
if( key ){
|
rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
|
||||||
rc = sqlite3BtreeKey(pCur, offset, amt, pMem->z);
|
|
||||||
}else{
|
|
||||||
rc = sqlite3BtreeData(pCur, offset, amt, pMem->z);
|
|
||||||
}
|
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
pMem->z[amt] = 0;
|
pMem->z[amt] = 0;
|
||||||
pMem->z[amt+1] = 0;
|
pMem->z[amt+1] = 0;
|
||||||
@@ -978,7 +972,6 @@ int sqlite3VdbeMemFromBtree(
|
|||||||
BtCursor *pCur, /* Cursor pointing at record to retrieve. */
|
BtCursor *pCur, /* Cursor pointing at record to retrieve. */
|
||||||
u32 offset, /* Offset from the start of data to return bytes from. */
|
u32 offset, /* Offset from the start of data to return bytes from. */
|
||||||
u32 amt, /* Number of bytes to return. */
|
u32 amt, /* Number of bytes to return. */
|
||||||
int key, /* If true, retrieve from the btree key, not data. */
|
|
||||||
Mem *pMem /* OUT: Return data in this Mem structure. */
|
Mem *pMem /* OUT: Return data in this Mem structure. */
|
||||||
){
|
){
|
||||||
char *zData; /* Data from the btree layer */
|
char *zData; /* Data from the btree layer */
|
||||||
@@ -999,7 +992,7 @@ int sqlite3VdbeMemFromBtree(
|
|||||||
pMem->flags = MEM_Blob|MEM_Ephem;
|
pMem->flags = MEM_Blob|MEM_Ephem;
|
||||||
pMem->n = (int)amt;
|
pMem->n = (int)amt;
|
||||||
}else{
|
}else{
|
||||||
rc = vdbeMemFromBtreeResize(pCur, offset, amt, key, pMem);
|
rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Reference in New Issue
Block a user