]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Since numeric affinity is the most common case, check it first. Interchange
authordrh <drh@noemail.net>
Thu, 18 Sep 2014 14:36:00 +0000 (14:36 +0000)
committerdrh <drh@noemail.net>
Thu, 18 Sep 2014 14:36:00 +0000 (14:36 +0000)
the NONE and TEXT affinity codes for easier checking of no affinity.

FossilOrigin-Name: 4ef4c9a7c8510203bce0941dda2f76ded8da1de2

manifest
manifest.uuid
src/build.c
src/sqliteInt.h
src/vdbe.c

index c14922f59d9e51f9affd5947f83444a78bdf61e1..00c2f35ee97b02fdd28df4caf8ab79d39ec570c4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Modify\san\sassert()\swithin\ssqlite3PagerWalFramesize(),\sa\sfunction\sonly\sever\sused\sby\szipvfs,\sto\saccount\sfor\srecent\szipvfs\schanges.
-D 2014-09-18T09:59:28.052
+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-18T14:36:00.055
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -174,7 +174,7 @@ F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
 F src/btree.c 6aa61c0e3d20d1d1acc8fb33d8f0ebd675305d3c
 F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
 F src/btreeInt.h e0ecb5dba292722039a7540beb3fc448103273cc
-F src/build.c 047d7e1d2d89fa55134fa1d6b669c9c2983c0d11
+F src/build.c 8dbca25988045fbf2a33c9631c42706fa6449e60
 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
 F src/complete.c 535183afb3c75628b78ce82612931ac7cdf26f14
 F src/ctime.c 16cd19215d9fd849ee2b7509b092f2e0bbd6a958
@@ -231,7 +231,7 @@ F src/shell.c c00220cdd7f2027780bc25b78376c16dc24e4b7d
 F src/sqlite.h.in 8b018219ce988913e5977d5de9ab4beb33be23b6
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
-F src/sqliteInt.h 0803e900eb1882f7dd88e86ddcddd2d1b27c8d86
+F src/sqliteInt.h 9bb8f655b076e1b9ed7cfe0b8c181e758d937369
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
 F src/table.c 2e99ef7ef16187e17033d9398dc962ce22dab5cb
@@ -288,7 +288,7 @@ F src/update.c 729f6f18fc27740591d085e1172cebe311144bf0
 F src/utf.c 8f634b93d41c089029dd503161a7d3e685d59a9c
 F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8
 F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
-F src/vdbe.c 78606777e4ce5dba147ab75e71c0127b0d8d4c3d
+F src/vdbe.c 2caa3b1e32f3fddc60fecb2cfd66afe2c2eb96b1
 F src/vdbe.h 09f5b4e3719fa454f252322b1cdab5cf1f361327
 F src/vdbeInt.h f90b0de6153f50de630a5a113537efb47083812f
 F src/vdbeapi.c c02242df5e9e8d1001e0086f405953833f9c426b
@@ -1198,7 +1198,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 5192f964b2a85459553f1cea741b9791606ccc4e
-R e8be2bb63b11cad540f46beed0dd6c95
-U dan
-Z 6d111ffcef80c669aed6101b87cfb783
+P 3bd7c1b2faa2d4cc95b255633204006849bfd5e0
+R c1df8072077a2642e4ce7426502f62dc
+U drh
+Z 04ecbaaf95d3fdde0c1a120923b44258
index 273ff9d0ee70b806bb0fd5a0e1e75852094f68aa..2c7c5a518e4a8c3bcc05b4170122335cb5ba594c 100644 (file)
@@ -1 +1 @@
-3bd7c1b2faa2d4cc95b255633204006849bfd5e0
\ No newline at end of file
+4ef4c9a7c8510203bce0941dda2f76ded8da1de2
\ No newline at end of file
index 791f6f2033abc89a94c8a11b1d8e8783509e8703..0c02a56fe75d95a34961835ea3aac0d39285e4a9 100644 (file)
@@ -1177,7 +1177,7 @@ char sqlite3AffinityType(const char *zIn, u8 *pszEst){
   ** estimate is scaled so that the size of an integer is 1.  */
   if( pszEst ){
     *pszEst = 1;   /* default size is approx 4 bytes */
-    if( aff<=SQLITE_AFF_NONE ){
+    if( aff<SQLITE_AFF_NUMERIC ){
       if( zChar ){
         while( zChar[0] ){
           if( sqlite3Isdigit(zChar[0]) ){
@@ -1548,8 +1548,8 @@ static char *createTableStmt(sqlite3 *db, Table *p){
   zStmt[k++] = '(';
   for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
     static const char * const azType[] = {
-        /* SQLITE_AFF_TEXT    */ " TEXT",
         /* SQLITE_AFF_NONE    */ "",
+        /* SQLITE_AFF_TEXT    */ " TEXT",
         /* SQLITE_AFF_NUMERIC */ " NUM",
         /* SQLITE_AFF_INTEGER */ " INT",
         /* SQLITE_AFF_REAL    */ " REAL"
@@ -1561,15 +1561,15 @@ static char *createTableStmt(sqlite3 *db, Table *p){
     k += sqlite3Strlen30(&zStmt[k]);
     zSep = zSep2;
     identPut(zStmt, &k, pCol->zName);
-    assert( pCol->affinity-SQLITE_AFF_TEXT >= 0 );
-    assert( pCol->affinity-SQLITE_AFF_TEXT < ArraySize(azType) );
-    testcase( pCol->affinity==SQLITE_AFF_TEXT );
+    assert( pCol->affinity-SQLITE_AFF_NONE >= 0 );
+    assert( pCol->affinity-SQLITE_AFF_NONE < ArraySize(azType) );
     testcase( pCol->affinity==SQLITE_AFF_NONE );
+    testcase( pCol->affinity==SQLITE_AFF_TEXT );
     testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
     testcase( pCol->affinity==SQLITE_AFF_INTEGER );
     testcase( pCol->affinity==SQLITE_AFF_REAL );
     
-    zType = azType[pCol->affinity - SQLITE_AFF_TEXT];
+    zType = azType[pCol->affinity - SQLITE_AFF_NONE];
     len = sqlite3Strlen30(zType);
     assert( pCol->affinity==SQLITE_AFF_NONE 
             || pCol->affinity==sqlite3AffinityType(zType, 0) );
index fd3731d8176643d4db5f88822affe1357662d3e7..ea8ad4573f6e33d462ded18945d17204c432b39a 100644 (file)
@@ -1427,10 +1427,10 @@ struct CollSeq {
 ** used as the P4 operand, they will be more readable.
 **
 ** 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     'b'
+#define SQLITE_AFF_NONE     'a'
+#define SQLITE_AFF_TEXT     'b'
 #define SQLITE_AFF_NUMERIC  'c'
 #define SQLITE_AFF_INTEGER  'd'
 #define SQLITE_AFF_REAL     'e'
index f964a73878ea082553140837730ee41f125925d4..1ff33b3e49f1891110a7b3f0fbd2eae95fb5e7f4 100644 (file)
@@ -277,15 +277,7 @@ static void applyAffinity(
   char affinity,      /* The affinity to be applied */
   u8 enc              /* Use this text encoding */
 ){
-  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);
-    }
-  }else if( affinity!=SQLITE_AFF_NONE ){
+  if( affinity>=SQLITE_AFF_NUMERIC ){
     assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL
              || affinity==SQLITE_AFF_NUMERIC );
     if( (pRec->flags & MEM_Int)==0 ){
@@ -295,6 +287,14 @@ static void applyAffinity(
         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.
 */
 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_NONE );
   testcase( pOp->p2==SQLITE_AFF_NUMERIC );
@@ -1904,7 +1904,7 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
   }else{
     /* Neither operand is NULL.  Do a comparison. */
     affinity = pOp->p5 & SQLITE_AFF_MASK;
-    if( affinity ){
+    if( affinity>=SQLITE_AFF_TEXT ){
       applyAffinity(pIn1, affinity, encoding);
       applyAffinity(pIn3, affinity, encoding);
       if( db->mallocFailed ) goto no_mem;