Tweaks to make OP_Column run a fraction faster. (CVS 2941)
FossilOrigin-Name: 2d74cc22de2aa59329b1ea5c26acd6ebe46e16c2
This commit is contained in:
parent
9792eeff95
commit
dedf45b260
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Avoid\sparsing\san\sentire\srecord\sheader\swhen\sit\sis\snot\srequired.\s(CVS\s2940)
|
C Tweaks\sto\smake\sOP_Column\srun\sa\sfraction\sfaster.\s(CVS\s2941)
|
||||||
D 2006-01-13T15:58:43
|
D 2006-01-13T17:12:01
|
||||||
F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
|
F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
|
||||||
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
|
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@ -87,7 +87,7 @@ F src/update.c 261d75c702c2852d1a64274d7c414485e6f2d177
|
|||||||
F src/utf.c 5ab8ca05d4e9ec81174b010f01ab12a232f0087d
|
F src/utf.c 5ab8ca05d4e9ec81174b010f01ab12a232f0087d
|
||||||
F src/util.c b26be916edd1c991450cccc6503356c4f776598b
|
F src/util.c b26be916edd1c991450cccc6503356c4f776598b
|
||||||
F src/vacuum.c 21a3c7f6f7be86bb1182fbc3df416ad702435b9e
|
F src/vacuum.c 21a3c7f6f7be86bb1182fbc3df416ad702435b9e
|
||||||
F src/vdbe.c e2f081425c3b2be6e7ff25fbb2f3f70fa95413ee
|
F src/vdbe.c bf64026224ade859b32e6c01fcf292fbf069cb95
|
||||||
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
|
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
|
||||||
F src/vdbeInt.h 5451cf71f229e366ac543607c0a17f36e5737ea9
|
F src/vdbeInt.h 5451cf71f229e366ac543607c0a17f36e5737ea9
|
||||||
F src/vdbeapi.c afd3837cea0dec93dcb4724d073c84fa0da68e23
|
F src/vdbeapi.c afd3837cea0dec93dcb4724d073c84fa0da68e23
|
||||||
@ -340,7 +340,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P 55b7dfaf4d3a6d01fffdaf1707e88bcd215d7333
|
P 0de729d9144afba144811799f65e32140c14ef8a
|
||||||
R 07d8c70ff570eb317ee47042ddb86743
|
R 4fc53b80c7e70cf5aaa2736ccda17872
|
||||||
U danielk1977
|
U danielk1977
|
||||||
Z 7bb864839753b74a0c8dfa1447111caa
|
Z 8db44b8359d9daca4aa7858d0ea683db
|
||||||
|
@ -1 +1 @@
|
|||||||
0de729d9144afba144811799f65e32140c14ef8a
|
2d74cc22de2aa59329b1ea5c26acd6ebe46e16c2
|
53
src/vdbe.c
53
src/vdbe.c
@ -43,7 +43,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.528 2006/01/13 15:58:43 danielk1977 Exp $
|
** $Id: vdbe.c,v 1.529 2006/01/13 17:12:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@ -1883,10 +1883,7 @@ case OP_Column: {
|
|||||||
u32 *aType; /* aType[i] holds the numeric type of the i-th column */
|
u32 *aType; /* aType[i] holds the numeric type of the i-th column */
|
||||||
u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
|
u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
|
||||||
u32 nField; /* number of fields in the record */
|
u32 nField; /* number of fields in the record */
|
||||||
u32 szHdr; /* Number of bytes in the record header */
|
|
||||||
int len; /* The length of the serialized data for the column */
|
int len; /* The length of the serialized data for the column */
|
||||||
int offset = 0; /* Offset into the data */
|
|
||||||
int idx; /* Index into the header */
|
|
||||||
int i; /* Loop counter */
|
int i; /* Loop counter */
|
||||||
char *zData; /* Part of the record being decoded */
|
char *zData; /* Part of the record being decoded */
|
||||||
Mem sMem; /* For storing the record being decoded */
|
Mem sMem; /* For storing the record being decoded */
|
||||||
@ -1975,7 +1972,10 @@ case OP_Column: {
|
|||||||
aType = pC->aType;
|
aType = pC->aType;
|
||||||
aOffset = pC->aOffset;
|
aOffset = pC->aOffset;
|
||||||
}else{
|
}else{
|
||||||
int avail; /* Number of bytes of available data */
|
u8 *zIdx; /* Index into header */
|
||||||
|
u8 *zEndHdr; /* Pointer to first byte after the header */
|
||||||
|
u32 offset; /* Offset into the data */
|
||||||
|
int avail; /* Number of bytes of available data */
|
||||||
if( pC && pC->aType ){
|
if( pC && pC->aType ){
|
||||||
aType = pC->aType;
|
aType = pC->aType;
|
||||||
}else{
|
}else{
|
||||||
@ -2007,8 +2007,7 @@ case OP_Column: {
|
|||||||
pC->aRow = 0;
|
pC->aRow = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
idx = GetVarint((u8*)zData, szHdr);
|
zIdx = (u8 *)GetVarint((u8*)zData, offset);
|
||||||
|
|
||||||
|
|
||||||
/* The KeyFetch() or DataFetch() above are fast and will get the entire
|
/* The KeyFetch() or DataFetch() above are fast and will get the entire
|
||||||
** record header in most cases. But they will fail to get the complete
|
** record header in most cases. But they will fail to get the complete
|
||||||
@ -2016,46 +2015,44 @@ case OP_Column: {
|
|||||||
** in the B-Tree. When that happens, use sqlite3VdbeMemFromBtree() to
|
** in the B-Tree. When that happens, use sqlite3VdbeMemFromBtree() to
|
||||||
** acquire the complete header text.
|
** acquire the complete header text.
|
||||||
*/
|
*/
|
||||||
if( !zRec && avail<szHdr ){
|
if( !zRec && avail<offset ){
|
||||||
rc = sqlite3VdbeMemFromBtree(pCrsr, 0, szHdr, pC->isIndex, &sMem);
|
rc = sqlite3VdbeMemFromBtree(pCrsr, 0, offset, pC->isIndex, &sMem);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
goto op_column_out;
|
goto op_column_out;
|
||||||
}
|
}
|
||||||
zData = sMem.z;
|
zData = sMem.z;
|
||||||
}
|
}
|
||||||
|
zEndHdr = (u8 *)zData + offset;
|
||||||
|
zIdx = zData + (int)zIdx;
|
||||||
|
|
||||||
/* Scan the header and use it to fill in the aType[] and aOffset[]
|
/* Scan the header and use it to fill in the aType[] and aOffset[]
|
||||||
** arrays. aType[i] will contain the type integer for the i-th
|
** arrays. aType[i] will contain the type integer for the i-th
|
||||||
** column and aOffset[i] will contain the offset from the beginning
|
** column and aOffset[i] will contain the offset from the beginning
|
||||||
** of the record to the start of the data for the i-th column
|
** of the record to the start of the data for the i-th column
|
||||||
*/
|
*/
|
||||||
offset = szHdr;
|
for(i=0; i<nField; i++){
|
||||||
assert( offset>0 );
|
if( zIdx<zEndHdr ){
|
||||||
i = 0;
|
aOffset[i] = offset;
|
||||||
while( idx<szHdr && i<nField && offset<=payloadSize ){
|
zIdx += GetVarint(zIdx, aType[i]);
|
||||||
aOffset[i] = offset;
|
offset += sqlite3VdbeSerialTypeLen(aType[i]);
|
||||||
idx += GetVarint((u8*)&zData[idx], aType[i]);
|
}else{
|
||||||
offset += sqlite3VdbeSerialTypeLen(aType[i]);
|
/* If i is less that nField, then there are less fields in this
|
||||||
i++;
|
** record than SetNumColumns indicated there are columns in the
|
||||||
|
** table. Set the offset for any extra columns not present in
|
||||||
|
** the record to 0. This tells code below to push a NULL onto the
|
||||||
|
** stack instead of deserializing a value from the record.
|
||||||
|
*/
|
||||||
|
aOffset[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Release(&sMem);
|
Release(&sMem);
|
||||||
sMem.flags = MEM_Null;
|
sMem.flags = MEM_Null;
|
||||||
|
|
||||||
/* If i is less that nField, then there are less fields in this
|
|
||||||
** record than SetNumColumns indicated there are columns in the
|
|
||||||
** table. Set the offset for any extra columns not present in
|
|
||||||
** the record to 0. This tells code below to push a NULL onto the
|
|
||||||
** stack instead of deserializing a value from the record.
|
|
||||||
*/
|
|
||||||
while( i<nField ){
|
|
||||||
aOffset[i++] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have read more header data than was contained in the header,
|
/* If we have read more header data than was contained in the header,
|
||||||
** or if the end of the last field appears to be past the end of the
|
** or if the end of the last field appears to be past the end of the
|
||||||
** record, then we must be dealing with a corrupt database.
|
** record, then we must be dealing with a corrupt database.
|
||||||
*/
|
*/
|
||||||
if( idx>szHdr || offset>payloadSize ){
|
if( zIdx>zEndHdr || offset>payloadSize ){
|
||||||
rc = SQLITE_CORRUPT_BKPT;
|
rc = SQLITE_CORRUPT_BKPT;
|
||||||
goto op_column_out;
|
goto op_column_out;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user