mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Since numeric affinity is the most common case, check it first. Interchange
the NONE and TEXT affinity codes for easier checking of no affinity. FossilOrigin-Name: 4ef4c9a7c8510203bce0941dda2f76ded8da1de2
This commit is contained in:
18
manifest
18
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Modify\san\sassert()\swithin\ssqlite3PagerWalFramesize(),\sa\sfunction\sonly\sever\sused\sby\szipvfs,\sto\saccount\sfor\srecent\szipvfs\schanges.
|
C Since\snumeric\saffinity\sis\sthe\smost\scommon\scase,\scheck\sit\sfirst.\s\sInterchange\nthe\sNONE\sand\sTEXT\saffinity\scodes\sfor\seasier\schecking\sof\sno\saffinity.
|
||||||
D 2014-09-18T09:59:28.052
|
D 2014-09-18T14:36:00.055
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
|
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -174,7 +174,7 @@ F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
|
|||||||
F src/btree.c 6aa61c0e3d20d1d1acc8fb33d8f0ebd675305d3c
|
F src/btree.c 6aa61c0e3d20d1d1acc8fb33d8f0ebd675305d3c
|
||||||
F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
|
F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
|
||||||
F src/btreeInt.h e0ecb5dba292722039a7540beb3fc448103273cc
|
F src/btreeInt.h e0ecb5dba292722039a7540beb3fc448103273cc
|
||||||
F src/build.c 047d7e1d2d89fa55134fa1d6b669c9c2983c0d11
|
F src/build.c 8dbca25988045fbf2a33c9631c42706fa6449e60
|
||||||
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
|
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
|
||||||
F src/complete.c 535183afb3c75628b78ce82612931ac7cdf26f14
|
F src/complete.c 535183afb3c75628b78ce82612931ac7cdf26f14
|
||||||
F src/ctime.c 16cd19215d9fd849ee2b7509b092f2e0bbd6a958
|
F src/ctime.c 16cd19215d9fd849ee2b7509b092f2e0bbd6a958
|
||||||
@@ -231,7 +231,7 @@ F src/shell.c c00220cdd7f2027780bc25b78376c16dc24e4b7d
|
|||||||
F src/sqlite.h.in 8b018219ce988913e5977d5de9ab4beb33be23b6
|
F src/sqlite.h.in 8b018219ce988913e5977d5de9ab4beb33be23b6
|
||||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
||||||
F src/sqliteInt.h 0803e900eb1882f7dd88e86ddcddd2d1b27c8d86
|
F src/sqliteInt.h 9bb8f655b076e1b9ed7cfe0b8c181e758d937369
|
||||||
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||||
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
||||||
F src/table.c 2e99ef7ef16187e17033d9398dc962ce22dab5cb
|
F src/table.c 2e99ef7ef16187e17033d9398dc962ce22dab5cb
|
||||||
@@ -288,7 +288,7 @@ F src/update.c 729f6f18fc27740591d085e1172cebe311144bf0
|
|||||||
F src/utf.c 8f634b93d41c089029dd503161a7d3e685d59a9c
|
F src/utf.c 8f634b93d41c089029dd503161a7d3e685d59a9c
|
||||||
F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8
|
F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8
|
||||||
F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
|
F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
|
||||||
F src/vdbe.c 78606777e4ce5dba147ab75e71c0127b0d8d4c3d
|
F src/vdbe.c 2caa3b1e32f3fddc60fecb2cfd66afe2c2eb96b1
|
||||||
F src/vdbe.h 09f5b4e3719fa454f252322b1cdab5cf1f361327
|
F src/vdbe.h 09f5b4e3719fa454f252322b1cdab5cf1f361327
|
||||||
F src/vdbeInt.h f90b0de6153f50de630a5a113537efb47083812f
|
F src/vdbeInt.h f90b0de6153f50de630a5a113537efb47083812f
|
||||||
F src/vdbeapi.c c02242df5e9e8d1001e0086f405953833f9c426b
|
F src/vdbeapi.c c02242df5e9e8d1001e0086f405953833f9c426b
|
||||||
@@ -1198,7 +1198,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 5192f964b2a85459553f1cea741b9791606ccc4e
|
P 3bd7c1b2faa2d4cc95b255633204006849bfd5e0
|
||||||
R e8be2bb63b11cad540f46beed0dd6c95
|
R c1df8072077a2642e4ce7426502f62dc
|
||||||
U dan
|
U drh
|
||||||
Z 6d111ffcef80c669aed6101b87cfb783
|
Z 04ecbaaf95d3fdde0c1a120923b44258
|
||||||
|
@@ -1 +1 @@
|
|||||||
3bd7c1b2faa2d4cc95b255633204006849bfd5e0
|
4ef4c9a7c8510203bce0941dda2f76ded8da1de2
|
12
src/build.c
12
src/build.c
@@ -1177,7 +1177,7 @@ char sqlite3AffinityType(const char *zIn, u8 *pszEst){
|
|||||||
** estimate is scaled so that the size of an integer is 1. */
|
** estimate is scaled so that the size of an integer is 1. */
|
||||||
if( pszEst ){
|
if( pszEst ){
|
||||||
*pszEst = 1; /* default size is approx 4 bytes */
|
*pszEst = 1; /* default size is approx 4 bytes */
|
||||||
if( aff<=SQLITE_AFF_NONE ){
|
if( aff<SQLITE_AFF_NUMERIC ){
|
||||||
if( zChar ){
|
if( zChar ){
|
||||||
while( zChar[0] ){
|
while( zChar[0] ){
|
||||||
if( sqlite3Isdigit(zChar[0]) ){
|
if( sqlite3Isdigit(zChar[0]) ){
|
||||||
@@ -1548,8 +1548,8 @@ static char *createTableStmt(sqlite3 *db, Table *p){
|
|||||||
zStmt[k++] = '(';
|
zStmt[k++] = '(';
|
||||||
for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
|
for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
|
||||||
static const char * const azType[] = {
|
static const char * const azType[] = {
|
||||||
/* SQLITE_AFF_TEXT */ " TEXT",
|
|
||||||
/* SQLITE_AFF_NONE */ "",
|
/* SQLITE_AFF_NONE */ "",
|
||||||
|
/* SQLITE_AFF_TEXT */ " TEXT",
|
||||||
/* SQLITE_AFF_NUMERIC */ " NUM",
|
/* SQLITE_AFF_NUMERIC */ " NUM",
|
||||||
/* SQLITE_AFF_INTEGER */ " INT",
|
/* SQLITE_AFF_INTEGER */ " INT",
|
||||||
/* SQLITE_AFF_REAL */ " REAL"
|
/* SQLITE_AFF_REAL */ " REAL"
|
||||||
@@ -1561,15 +1561,15 @@ static char *createTableStmt(sqlite3 *db, Table *p){
|
|||||||
k += sqlite3Strlen30(&zStmt[k]);
|
k += sqlite3Strlen30(&zStmt[k]);
|
||||||
zSep = zSep2;
|
zSep = zSep2;
|
||||||
identPut(zStmt, &k, pCol->zName);
|
identPut(zStmt, &k, pCol->zName);
|
||||||
assert( pCol->affinity-SQLITE_AFF_TEXT >= 0 );
|
assert( pCol->affinity-SQLITE_AFF_NONE >= 0 );
|
||||||
assert( pCol->affinity-SQLITE_AFF_TEXT < ArraySize(azType) );
|
assert( pCol->affinity-SQLITE_AFF_NONE < ArraySize(azType) );
|
||||||
testcase( pCol->affinity==SQLITE_AFF_TEXT );
|
|
||||||
testcase( pCol->affinity==SQLITE_AFF_NONE );
|
testcase( pCol->affinity==SQLITE_AFF_NONE );
|
||||||
|
testcase( pCol->affinity==SQLITE_AFF_TEXT );
|
||||||
testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
|
testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
|
||||||
testcase( pCol->affinity==SQLITE_AFF_INTEGER );
|
testcase( pCol->affinity==SQLITE_AFF_INTEGER );
|
||||||
testcase( pCol->affinity==SQLITE_AFF_REAL );
|
testcase( pCol->affinity==SQLITE_AFF_REAL );
|
||||||
|
|
||||||
zType = azType[pCol->affinity - SQLITE_AFF_TEXT];
|
zType = azType[pCol->affinity - SQLITE_AFF_NONE];
|
||||||
len = sqlite3Strlen30(zType);
|
len = sqlite3Strlen30(zType);
|
||||||
assert( pCol->affinity==SQLITE_AFF_NONE
|
assert( pCol->affinity==SQLITE_AFF_NONE
|
||||||
|| pCol->affinity==sqlite3AffinityType(zType, 0) );
|
|| pCol->affinity==sqlite3AffinityType(zType, 0) );
|
||||||
|
@@ -1427,10 +1427,10 @@ struct CollSeq {
|
|||||||
** used as the P4 operand, they will be more readable.
|
** used as the P4 operand, they will be more readable.
|
||||||
**
|
**
|
||||||
** Note also that the numeric types are grouped together so that testing
|
** Note also that the numeric types are grouped together so that testing
|
||||||
** for a numeric type is a single comparison.
|
** for a numeric type is a single comparison. And the NONE type is first.
|
||||||
*/
|
*/
|
||||||
#define SQLITE_AFF_TEXT 'a'
|
#define SQLITE_AFF_NONE 'a'
|
||||||
#define SQLITE_AFF_NONE 'b'
|
#define SQLITE_AFF_TEXT 'b'
|
||||||
#define SQLITE_AFF_NUMERIC 'c'
|
#define SQLITE_AFF_NUMERIC 'c'
|
||||||
#define SQLITE_AFF_INTEGER 'd'
|
#define SQLITE_AFF_INTEGER 'd'
|
||||||
#define SQLITE_AFF_REAL 'e'
|
#define SQLITE_AFF_REAL 'e'
|
||||||
|
22
src/vdbe.c
22
src/vdbe.c
@@ -277,15 +277,7 @@ static void applyAffinity(
|
|||||||
char affinity, /* The affinity to be applied */
|
char affinity, /* The affinity to be applied */
|
||||||
u8 enc /* Use this text encoding */
|
u8 enc /* Use this text encoding */
|
||||||
){
|
){
|
||||||
if( affinity==SQLITE_AFF_TEXT ){
|
if( affinity>=SQLITE_AFF_NUMERIC ){
|
||||||
/* Only attempt the conversion to TEXT if there is an integer or real
|
|
||||||
** representation (blob and NULL do not get converted) but no string
|
|
||||||
** representation.
|
|
||||||
*/
|
|
||||||
if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){
|
|
||||||
sqlite3VdbeMemStringify(pRec, enc, 1);
|
|
||||||
}
|
|
||||||
}else if( affinity!=SQLITE_AFF_NONE ){
|
|
||||||
assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL
|
assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL
|
||||||
|| affinity==SQLITE_AFF_NUMERIC );
|
|| affinity==SQLITE_AFF_NUMERIC );
|
||||||
if( (pRec->flags & MEM_Int)==0 ){
|
if( (pRec->flags & MEM_Int)==0 ){
|
||||||
@@ -295,6 +287,14 @@ static void applyAffinity(
|
|||||||
sqlite3VdbeIntegerAffinity(pRec);
|
sqlite3VdbeIntegerAffinity(pRec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else if( affinity==SQLITE_AFF_TEXT ){
|
||||||
|
/* Only attempt the conversion to TEXT if there is an integer or real
|
||||||
|
** representation (blob and NULL do not get converted) but no string
|
||||||
|
** representation.
|
||||||
|
*/
|
||||||
|
if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){
|
||||||
|
sqlite3VdbeMemStringify(pRec, enc, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1754,7 +1754,7 @@ case OP_RealAffinity: { /* in1 */
|
|||||||
** A NULL value is not changed by this routine. It remains NULL.
|
** A NULL value is not changed by this routine. It remains NULL.
|
||||||
*/
|
*/
|
||||||
case OP_Cast: { /* in1 */
|
case OP_Cast: { /* in1 */
|
||||||
assert( pOp->p2>=SQLITE_AFF_TEXT && pOp->p2<=SQLITE_AFF_REAL );
|
assert( pOp->p2>=SQLITE_AFF_NONE && pOp->p2<=SQLITE_AFF_REAL );
|
||||||
testcase( pOp->p2==SQLITE_AFF_TEXT );
|
testcase( pOp->p2==SQLITE_AFF_TEXT );
|
||||||
testcase( pOp->p2==SQLITE_AFF_NONE );
|
testcase( pOp->p2==SQLITE_AFF_NONE );
|
||||||
testcase( pOp->p2==SQLITE_AFF_NUMERIC );
|
testcase( pOp->p2==SQLITE_AFF_NUMERIC );
|
||||||
@@ -1904,7 +1904,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
|
|||||||
}else{
|
}else{
|
||||||
/* Neither operand is NULL. Do a comparison. */
|
/* Neither operand is NULL. Do a comparison. */
|
||||||
affinity = pOp->p5 & SQLITE_AFF_MASK;
|
affinity = pOp->p5 & SQLITE_AFF_MASK;
|
||||||
if( affinity ){
|
if( affinity>=SQLITE_AFF_TEXT ){
|
||||||
applyAffinity(pIn1, affinity, encoding);
|
applyAffinity(pIn1, affinity, encoding);
|
||||||
applyAffinity(pIn3, affinity, encoding);
|
applyAffinity(pIn3, affinity, encoding);
|
||||||
if( db->mallocFailed ) goto no_mem;
|
if( db->mallocFailed ) goto no_mem;
|
||||||
|
Reference in New Issue
Block a user