/ Check-in [ed174ccf]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Pull in the latest 3.9.0 tweaks from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1:ed174ccf0ae615647ba026fed649d26dc9a98640
User & Date: drh 2015-10-10 20:35:10
Context
2015-10-13
20:42
Merge in the final few changes before the 3.9.0 release. check-in: e1afdbb5 user: drh tags: sessions
2015-10-10
20:35
Pull in the latest 3.9.0 tweaks from trunk. check-in: ed174ccf user: drh tags: sessions
16:41
Work around a "security feature" bug in memcpy() on OpenBSD. check-in: fab6f090 user: drh tags: trunk
2015-10-09
15:29
Merge the version 3.9.0 changes and the incorporation of JSON1 and FTS5 into the amalgamation from trunk. check-in: c1d96fb6 user: drh tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_main.c.

  2211   2211     fts5_extension_function xFunc,  /* Aux. function implementation */
  2212   2212     void(*xDestroy)(void*)          /* Destructor for pUserData */
  2213   2213   ){
  2214   2214     Fts5Global *pGlobal = (Fts5Global*)pApi;
  2215   2215     int rc = sqlite3_overload_function(pGlobal->db, zName, -1);
  2216   2216     if( rc==SQLITE_OK ){
  2217   2217       Fts5Auxiliary *pAux;
         2218  +    int nName;                      /* Size of zName in bytes, including \0 */
  2218   2219       int nByte;                      /* Bytes of space to allocate */
  2219   2220   
  2220         -    nByte = sizeof(Fts5Auxiliary) + strlen(zName) + 1;
         2221  +    nName = (int)strlen(zName) + 1;
         2222  +    nByte = sizeof(Fts5Auxiliary) + nName;
  2221   2223       pAux = (Fts5Auxiliary*)sqlite3_malloc(nByte);
  2222   2224       if( pAux ){
  2223   2225         memset(pAux, 0, nByte);
  2224   2226         pAux->zFunc = (char*)&pAux[1];
  2225         -      strcpy(pAux->zFunc, zName);
         2227  +      memcpy(pAux->zFunc, zName, nName);
  2226   2228         pAux->pGlobal = pGlobal;
  2227   2229         pAux->pUserData = pUserData;
  2228   2230         pAux->xFunc = xFunc;
  2229   2231         pAux->xDestroy = xDestroy;
  2230   2232         pAux->pNext = pGlobal->pAux;
  2231   2233         pGlobal->pAux = pAux;
  2232   2234       }else{
................................................................................
  2246   2248     const char *zName,              /* Name of new function */
  2247   2249     void *pUserData,                /* User data for aux. function */
  2248   2250     fts5_tokenizer *pTokenizer,     /* Tokenizer implementation */
  2249   2251     void(*xDestroy)(void*)          /* Destructor for pUserData */
  2250   2252   ){
  2251   2253     Fts5Global *pGlobal = (Fts5Global*)pApi;
  2252   2254     Fts5TokenizerModule *pNew;
         2255  +  int nName;                      /* Size of zName and its \0 terminator */
  2253   2256     int nByte;                      /* Bytes of space to allocate */
  2254   2257     int rc = SQLITE_OK;
  2255   2258   
  2256         -  nByte = sizeof(Fts5TokenizerModule) + strlen(zName) + 1;
         2259  +  nName = (int)strlen(zName) + 1;
         2260  +  nByte = sizeof(Fts5TokenizerModule) + nName;
  2257   2261     pNew = (Fts5TokenizerModule*)sqlite3_malloc(nByte);
  2258   2262     if( pNew ){
  2259   2263       memset(pNew, 0, nByte);
  2260   2264       pNew->zName = (char*)&pNew[1];
  2261         -    strcpy(pNew->zName, zName);
         2265  +    memcpy(pNew->zName, zName, nName);
  2262   2266       pNew->pUserData = pUserData;
  2263   2267       pNew->x = *pTokenizer;
  2264   2268       pNew->xDestroy = xDestroy;
  2265   2269       pNew->pNext = pGlobal->pTok;
  2266   2270       pGlobal->pTok = pNew;
  2267   2271       if( pNew->pNext==0 ){
  2268   2272         pGlobal->pDfltTok = pNew;
................................................................................
  2490   2494     return fts5Init(db);
  2491   2495   }
  2492   2496   #else
  2493   2497   int sqlite3Fts5Init(sqlite3 *db){
  2494   2498     return fts5Init(db);
  2495   2499   }
  2496   2500   #endif
  2497         -

Changes to ext/misc/json1.c.

    24     24   #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1)
    25     25   #if !defined(_SQLITEINT_H_)
    26     26   #include "sqlite3ext.h"
    27     27   #endif
    28     28   SQLITE_EXTENSION_INIT1
    29     29   #include <assert.h>
    30     30   #include <string.h>
    31         -#include <ctype.h>
           31  +#include <ctype.h>  /* amalgamator: keep */
    32     32   #include <stdlib.h>
    33     33   #include <stdarg.h>
    34     34   
    35     35   #define UNUSED_PARAM(X)  (void)(X)
           36  +
           37  +#ifndef LARGEST_INT64
           38  +# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
           39  +# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
           40  +#endif
    36     41   
    37     42   /*
    38     43   ** Versions of isspace(), isalnum() and isdigit() to which it is safe
    39     44   ** to pass signed char values.
    40     45   */
    41     46   #define safe_isdigit(x) isdigit((unsigned char)(x))
    42     47   #define safe_isalnum(x) isalnum((unsigned char)(x))
................................................................................
    62     67     0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,
    63     68     0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,
    64     69     0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,
    65     70     0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,
    66     71   };
    67     72   #define safe_isspace(x) (jsonIsSpace[(unsigned char)x])
    68     73   
    69         -/* Unsigned integer types */
    70         -typedef sqlite3_uint64 u64;
    71         -typedef unsigned int u32;
    72         -typedef unsigned char u8;
           74  +#ifndef SQLITE_AMALGAMATION
           75  +  /* Unsigned integer types.  These are already defined in the sqliteInt.h,
           76  +  ** but the definitions need to be repeated for separate compilation. */
           77  +  typedef sqlite3_uint64 u64;
           78  +  typedef unsigned int u32;
           79  +  typedef unsigned char u8;
           80  +#endif
    73     81   
    74     82   /* Objects */
    75     83   typedef struct JsonString JsonString;
    76     84   typedef struct JsonNode JsonNode;
    77     85   typedef struct JsonParse JsonParse;
    78     86   
    79     87   /* An instance of this object represents a JSON string
................................................................................
   474    482         sqlite3_result_int(pCtx, 1);
   475    483         break;
   476    484       }
   477    485       case JSON_FALSE: {
   478    486         sqlite3_result_int(pCtx, 0);
   479    487         break;
   480    488       }
   481         -    case JSON_REAL: {
   482         -      double r = strtod(pNode->u.zJContent, 0);
   483         -      sqlite3_result_double(pCtx, r);
   484         -      break;
   485         -    }
   486    489       case JSON_INT: {
   487    490         sqlite3_int64 i = 0;
   488    491         const char *z = pNode->u.zJContent;
   489    492         if( z[0]=='-' ){ z++; }
   490         -      while( z[0]>='0' && z[0]<='9' ){ i = i*10 + *(z++) - '0'; }
          493  +      while( z[0]>='0' && z[0]<='9' ){
          494  +        unsigned v = *(z++) - '0';
          495  +        if( i>=LARGEST_INT64/10 ){
          496  +          if( i>LARGEST_INT64/10 ) goto int_as_real;
          497  +          if( z[0]>='0' && z[0]<='9' ) goto int_as_real;
          498  +          if( v==9 ) goto int_as_real;
          499  +          if( v==8 ){
          500  +            if( pNode->u.zJContent[0]=='-' ){
          501  +              sqlite3_result_int64(pCtx, SMALLEST_INT64);
          502  +              goto int_done;
          503  +            }else{
          504  +              goto int_as_real;
          505  +            }
          506  +          }
          507  +        }
          508  +        i = i*10 + v;
          509  +      }
   491    510         if( pNode->u.zJContent[0]=='-' ){ i = -i; }
   492    511         sqlite3_result_int64(pCtx, i);
          512  +      int_done:
          513  +      break;
          514  +      int_as_real: /* fall through to real */;
          515  +    }
          516  +    case JSON_REAL: {
          517  +      double r = strtod(pNode->u.zJContent, 0);
          518  +      sqlite3_result_double(pCtx, r);
   493    519         break;
   494    520       }
   495    521       case JSON_STRING: {
   496    522   #if 0 /* Never happens because JNODE_RAW is only set by json_set(),
   497    523         ** json_insert() and json_replace() and those routines do not
   498    524         ** call jsonReturn() */
   499    525         if( pNode->jnFlags & JNODE_RAW ){

Changes to src/alter.c.

   598    598     v = sqlite3GetVdbe(pParse);
   599    599     /* The VDBE should have been allocated before this routine is called.
   600    600     ** If that allocation failed, we would have quit before reaching this
   601    601     ** point */
   602    602     if( ALWAYS(v) ){
   603    603       int r1 = sqlite3GetTempReg(pParse);
   604    604       int r2 = sqlite3GetTempReg(pParse);
   605         -    int j1;
          605  +    int addr1;
   606    606       sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
   607    607       sqlite3VdbeUsesBtree(v, iDb);
   608    608       sqlite3VdbeAddOp2(v, OP_Integer, minFormat, r2);
   609         -    j1 = sqlite3VdbeAddOp3(v, OP_Ge, r2, 0, r1);
          609  +    addr1 = sqlite3VdbeAddOp3(v, OP_Ge, r2, 0, r1);
   610    610       sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); VdbeCoverage(v);
   611    611       sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2);
   612         -    sqlite3VdbeJumpHere(v, j1);
          612  +    sqlite3VdbeJumpHere(v, addr1);
   613    613       sqlite3ReleaseTempReg(pParse, r1);
   614    614       sqlite3ReleaseTempReg(pParse, r2);
   615    615     }
   616    616   }
   617    617   
   618    618   /*
   619    619   ** This function is called after an "ALTER TABLE ... ADD" statement

Changes to src/btree.c.

  6495   6495       u8 *pSlot;
  6496   6496       sz = cachedCellSize(pCArray, i);
  6497   6497       if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){
  6498   6498         pData -= sz;
  6499   6499         if( pData<pBegin ) return 1;
  6500   6500         pSlot = pData;
  6501   6501       }
  6502         -    memcpy(pSlot, pCArray->apCell[i], sz);
         6502  +    /* pSlot and pCArray->apCell[i] will never overlap on a well-formed
         6503  +    ** database.  But they might for a corrupt database.  Hence use memmove()
         6504  +    ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */
         6505  +    assert( (pSlot+sz)<=pCArray->apCell[i]
         6506  +         || pSlot>=(pCArray->apCell[i]+sz)
         6507  +         || CORRUPT_DB );
         6508  +    memmove(pSlot, pCArray->apCell[i], sz);
  6503   6509       put2byte(pCellptr, (pSlot - aData));
  6504   6510       pCellptr += 2;
  6505   6511     }
  6506   6512     *ppData = pData;
  6507   6513     return 0;
  6508   6514   }
  6509   6515   

Changes to src/build.c.

   981    981     ** and allocate the record number for the table entry now.  Before any
   982    982     ** PRIMARY KEY or UNIQUE keywords are parsed.  Those keywords will cause
   983    983     ** indices to be created and the table record must come before the 
   984    984     ** indices.  Hence, the record number for the table must be allocated
   985    985     ** now.
   986    986     */
   987    987     if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){
   988         -    int j1;
          988  +    int addr1;
   989    989       int fileFormat;
   990    990       int reg1, reg2, reg3;
   991    991       /* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */
   992    992       static const char nullRow[] = { 6, 0, 0, 0, 0, 0 };
   993    993       sqlite3BeginWriteOperation(pParse, 1, iDb);
   994    994   
   995    995   #ifndef SQLITE_OMIT_VIRTUALTABLE
................................................................................
  1002   1002       ** set them now.
  1003   1003       */
  1004   1004       reg1 = pParse->regRowid = ++pParse->nMem;
  1005   1005       reg2 = pParse->regRoot = ++pParse->nMem;
  1006   1006       reg3 = ++pParse->nMem;
  1007   1007       sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);
  1008   1008       sqlite3VdbeUsesBtree(v, iDb);
  1009         -    j1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);
         1009  +    addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);
  1010   1010       fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?
  1011   1011                     1 : SQLITE_MAX_FILE_FORMAT;
  1012   1012       sqlite3VdbeAddOp2(v, OP_Integer, fileFormat, reg3);
  1013   1013       sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3);
  1014   1014       sqlite3VdbeAddOp2(v, OP_Integer, ENC(db), reg3);
  1015   1015       sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, reg3);
  1016         -    sqlite3VdbeJumpHere(v, j1);
         1016  +    sqlite3VdbeJumpHere(v, addr1);
  1017   1017   
  1018   1018       /* This just creates a place-holder record in the sqlite_master table.
  1019   1019       ** The record created does not contain anything yet.  It will be replaced
  1020   1020       ** by the real entry in code generated at sqlite3EndTable().
  1021   1021       **
  1022   1022       ** The rowid for the new entry is left in register pParse->regRowid.
  1023   1023       ** The root page number of the new table is left in reg pParse->regRoot.

Changes to src/expr.c.

  1591   1591   /*
  1592   1592   ** Generate code that checks the left-most column of index table iCur to see if
  1593   1593   ** it contains any NULL entries.  Cause the register at regHasNull to be set
  1594   1594   ** to a non-NULL value if iCur contains no NULLs.  Cause register regHasNull
  1595   1595   ** to be set to NULL if iCur contains one or more NULL values.
  1596   1596   */
  1597   1597   static void sqlite3SetHasNullFlag(Vdbe *v, int iCur, int regHasNull){
  1598         -  int j1;
         1598  +  int addr1;
  1599   1599     sqlite3VdbeAddOp2(v, OP_Integer, 0, regHasNull);
  1600         -  j1 = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);
         1600  +  addr1 = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);
  1601   1601     sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, regHasNull);
  1602   1602     sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
  1603   1603     VdbeComment((v, "first_entry_in(%d)", iCur));
  1604         -  sqlite3VdbeJumpHere(v, j1);
         1604  +  sqlite3VdbeJumpHere(v, addr1);
  1605   1605   }
  1606   1606   
  1607   1607   
  1608   1608   #ifndef SQLITE_OMIT_SUBQUERY
  1609   1609   /*
  1610   1610   ** The argument is an IN operator with a list (not a subquery) on the 
  1611   1611   ** right-hand side.  Return TRUE if that list is constant.
................................................................................
  2197   2197           sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse, r1, 1);
  2198   2198           VdbeCoverage(v);
  2199   2199         }else{
  2200   2200           /* In this branch, the RHS of the IN might contain a NULL and
  2201   2201           ** the presence of a NULL on the RHS makes a difference in the
  2202   2202           ** outcome.
  2203   2203           */
  2204         -        int j1;
         2204  +        int addr1;
  2205   2205     
  2206   2206           /* First check to see if the LHS is contained in the RHS.  If so,
  2207   2207           ** then the answer is TRUE the presence of NULLs in the RHS does
  2208   2208           ** not matter.  If the LHS is not contained in the RHS, then the
  2209   2209           ** answer is NULL if the RHS contains NULLs and the answer is
  2210   2210           ** FALSE if the RHS is NULL-free.
  2211   2211           */
  2212         -        j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);
         2212  +        addr1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);
  2213   2213           VdbeCoverage(v);
  2214   2214           sqlite3VdbeAddOp2(v, OP_IsNull, rRhsHasNull, destIfNull);
  2215   2215           VdbeCoverage(v);
  2216   2216           sqlite3VdbeGoto(v, destIfFalse);
  2217         -        sqlite3VdbeJumpHere(v, j1);
         2217  +        sqlite3VdbeJumpHere(v, addr1);
  2218   2218         }
  2219   2219       }
  2220   2220     }
  2221   2221     sqlite3ReleaseTempReg(pParse, r1);
  2222   2222     sqlite3ExprCachePop(pParse);
  2223   2223     VdbeComment((v, "end IN expr"));
  2224   2224   }

Changes to src/insert.c.

   309    309     AutoincInfo *p;
   310    310     Vdbe *v = pParse->pVdbe;
   311    311     sqlite3 *db = pParse->db;
   312    312   
   313    313     assert( v );
   314    314     for(p = pParse->pAinc; p; p = p->pNext){
   315    315       Db *pDb = &db->aDb[p->iDb];
   316         -    int j1;
          316  +    int addr1;
   317    317       int iRec;
   318    318       int memId = p->regCtr;
   319    319   
   320    320       iRec = sqlite3GetTempReg(pParse);
   321    321       assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );
   322    322       sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite);
   323         -    j1 = sqlite3VdbeAddOp1(v, OP_NotNull, memId+1); VdbeCoverage(v);
          323  +    addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, memId+1); VdbeCoverage(v);
   324    324       sqlite3VdbeAddOp2(v, OP_NewRowid, 0, memId+1);
   325         -    sqlite3VdbeJumpHere(v, j1);
          325  +    sqlite3VdbeJumpHere(v, addr1);
   326    326       sqlite3VdbeAddOp3(v, OP_MakeRecord, memId-1, 2, iRec);
   327    327       sqlite3VdbeAddOp3(v, OP_Insert, 0, iRec, memId+1);
   328    328       sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
   329    329       sqlite3VdbeAddOp0(v, OP_Close);
   330    330       sqlite3ReleaseTempReg(pParse, iRec);
   331    331     }
   332    332   }
................................................................................
   810    810       ** translated into a unique ID for the row.  But on a BEFORE trigger,
   811    811       ** we do not know what the unique ID will be (because the insert has
   812    812       ** not happened yet) so we substitute a rowid of -1
   813    813       */
   814    814       if( ipkColumn<0 ){
   815    815         sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);
   816    816       }else{
   817         -      int j1;
          817  +      int addr1;
   818    818         assert( !withoutRowid );
   819    819         if( useTempTable ){
   820    820           sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regCols);
   821    821         }else{
   822    822           assert( pSelect==0 );  /* Otherwise useTempTable is true */
   823    823           sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regCols);
   824    824         }
   825         -      j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); VdbeCoverage(v);
          825  +      addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); VdbeCoverage(v);
   826    826         sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);
   827         -      sqlite3VdbeJumpHere(v, j1);
          827  +      sqlite3VdbeJumpHere(v, addr1);
   828    828         sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); VdbeCoverage(v);
   829    829       }
   830    830   
   831    831       /* Cannot have triggers on a virtual table. If it were possible,
   832    832       ** this block would have to account for hidden column.
   833    833       */
   834    834       assert( !IsVirtual(pTab) );
................................................................................
   894    894             pOp->p3 = regAutoinc;
   895    895           }
   896    896         }
   897    897         /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid
   898    898         ** to generate a unique primary key value.
   899    899         */
   900    900         if( !appendFlag ){
   901         -        int j1;
          901  +        int addr1;
   902    902           if( !IsVirtual(pTab) ){
   903         -          j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); VdbeCoverage(v);
          903  +          addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); VdbeCoverage(v);
   904    904             sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
   905         -          sqlite3VdbeJumpHere(v, j1);
          905  +          sqlite3VdbeJumpHere(v, addr1);
   906    906           }else{
   907         -          j1 = sqlite3VdbeCurrentAddr(v);
   908         -          sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, j1+2); VdbeCoverage(v);
          907  +          addr1 = sqlite3VdbeCurrentAddr(v);
          908  +          sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, addr1+2); VdbeCoverage(v);
   909    909           }
   910    910           sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); VdbeCoverage(v);
   911    911         }
   912    912       }else if( IsVirtual(pTab) || withoutRowid ){
   913    913         sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid);
   914    914       }else{
   915    915         sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
................................................................................
  1155   1155     Index *pIdx;         /* Pointer to one of the indices */
  1156   1156     Index *pPk = 0;      /* The PRIMARY KEY index */
  1157   1157     sqlite3 *db;         /* Database connection */
  1158   1158     int i;               /* loop counter */
  1159   1159     int ix;              /* Index loop counter */
  1160   1160     int nCol;            /* Number of columns */
  1161   1161     int onError;         /* Conflict resolution strategy */
  1162         -  int j1;              /* Address of jump instruction */
         1162  +  int addr1;           /* Address of jump instruction */
  1163   1163     int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
  1164   1164     int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */
  1165   1165     int ipkTop = 0;      /* Top of the rowid change constraint check */
  1166   1166     int ipkBottom = 0;   /* Bottom of the rowid change constraint check */
  1167   1167     u8 isUpdate;         /* True if this is an UPDATE operation */
  1168   1168     u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */
  1169   1169     int regRowid = -1;   /* Register holding ROWID value */
................................................................................
  1226   1226         case OE_Ignore: {
  1227   1227           sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);
  1228   1228           VdbeCoverage(v);
  1229   1229           break;
  1230   1230         }
  1231   1231         default: {
  1232   1232           assert( onError==OE_Replace );
  1233         -        j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regNewData+1+i); VdbeCoverage(v);
         1233  +        addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regNewData+1+i);
         1234  +           VdbeCoverage(v);
  1234   1235           sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
  1235         -        sqlite3VdbeJumpHere(v, j1);
         1236  +        sqlite3VdbeJumpHere(v, addr1);
  1236   1237           break;
  1237   1238         }
  1238   1239       }
  1239   1240     }
  1240   1241   
  1241   1242     /* Test all CHECK constraints
  1242   1243     */

Changes to src/loadext.c.

   611    611   /*
   612    612   ** The auto-extension code added regardless of whether or not extension
   613    613   ** loading is supported.  We need a dummy sqlite3Apis pointer for that
   614    614   ** code if regular extension loading is not available.  This is that
   615    615   ** dummy pointer.
   616    616   */
   617    617   #ifdef SQLITE_OMIT_LOAD_EXTENSION
   618         -static const sqlite3_api_routines sqlite3Apis = { 0 };
          618  +static const sqlite3_api_routines sqlite3Apis;
   619    619   #endif
   620    620   
   621    621   
   622    622   /*
   623    623   ** The following object holds the list of automatically loaded
   624    624   ** extensions.
   625    625   **

Changes to src/select.c.

  2574   2574   
  2575   2575     addr = sqlite3VdbeCurrentAddr(v);
  2576   2576     iContinue = sqlite3VdbeMakeLabel(v);
  2577   2577   
  2578   2578     /* Suppress duplicates for UNION, EXCEPT, and INTERSECT 
  2579   2579     */
  2580   2580     if( regPrev ){
  2581         -    int j1, j2;
  2582         -    j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); VdbeCoverage(v);
  2583         -    j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,
         2581  +    int addr1, addr2;
         2582  +    addr1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); VdbeCoverage(v);
         2583  +    addr2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,
  2584   2584                                 (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);
  2585         -    sqlite3VdbeAddOp3(v, OP_Jump, j2+2, iContinue, j2+2); VdbeCoverage(v);
  2586         -    sqlite3VdbeJumpHere(v, j1);
         2585  +    sqlite3VdbeAddOp3(v, OP_Jump, addr2+2, iContinue, addr2+2); VdbeCoverage(v);
         2586  +    sqlite3VdbeJumpHere(v, addr1);
  2587   2587       sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);
  2588   2588       sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);
  2589   2589     }
  2590   2590     if( pParse->db->mallocFailed ) return 0;
  2591   2591   
  2592   2592     /* Suppress the first OFFSET entries if there is an OFFSET clause
  2593   2593     */
................................................................................
  2796   2796     int regLimitA;        /* Limit register for select-A */
  2797   2797     int regLimitB;        /* Limit register for select-A */
  2798   2798     int regPrev;          /* A range of registers to hold previous output */
  2799   2799     int savedLimit;       /* Saved value of p->iLimit */
  2800   2800     int savedOffset;      /* Saved value of p->iOffset */
  2801   2801     int labelCmpr;        /* Label for the start of the merge algorithm */
  2802   2802     int labelEnd;         /* Label for the end of the overall SELECT stmt */
  2803         -  int j1;               /* Jump instructions that get retargetted */
         2803  +  int addr1;            /* Jump instructions that get retargetted */
  2804   2804     int op;               /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */
  2805   2805     KeyInfo *pKeyDup = 0; /* Comparison information for duplicate removal */
  2806   2806     KeyInfo *pKeyMerge;   /* Comparison information for merging rows */
  2807   2807     sqlite3 *db;          /* Database connection */
  2808   2808     ExprList *pOrderBy;   /* The ORDER BY clause */
  2809   2809     int nOrderBy;         /* Number of terms in the ORDER BY clause */
  2810   2810     int *aPermute;        /* Mapping from ORDER BY terms to result set columns */
................................................................................
  2932   2932     sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);
  2933   2933     sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);
  2934   2934   
  2935   2935     /* Generate a coroutine to evaluate the SELECT statement to the
  2936   2936     ** left of the compound operator - the "A" select.
  2937   2937     */
  2938   2938     addrSelectA = sqlite3VdbeCurrentAddr(v) + 1;
  2939         -  j1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);
         2939  +  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);
  2940   2940     VdbeComment((v, "left SELECT"));
  2941   2941     pPrior->iLimit = regLimitA;
  2942   2942     explainSetInteger(iSub1, pParse->iNextSelectId);
  2943   2943     sqlite3Select(pParse, pPrior, &destA);
  2944   2944     sqlite3VdbeAddOp1(v, OP_EndCoroutine, regAddrA);
  2945         -  sqlite3VdbeJumpHere(v, j1);
         2945  +  sqlite3VdbeJumpHere(v, addr1);
  2946   2946   
  2947   2947     /* Generate a coroutine to evaluate the SELECT statement on 
  2948   2948     ** the right - the "B" select
  2949   2949     */
  2950   2950     addrSelectB = sqlite3VdbeCurrentAddr(v) + 1;
  2951         -  j1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrB, 0, addrSelectB);
         2951  +  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrB, 0, addrSelectB);
  2952   2952     VdbeComment((v, "right SELECT"));
  2953   2953     savedLimit = p->iLimit;
  2954   2954     savedOffset = p->iOffset;
  2955   2955     p->iLimit = regLimitB;
  2956   2956     p->iOffset = 0;  
  2957   2957     explainSetInteger(iSub2, pParse->iNextSelectId);
  2958   2958     sqlite3Select(pParse, p, &destB);
................................................................................
  3035   3035       sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);
  3036   3036     }
  3037   3037     sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);
  3038   3038     sqlite3VdbeGoto(v, labelCmpr);
  3039   3039   
  3040   3040     /* This code runs once to initialize everything.
  3041   3041     */
  3042         -  sqlite3VdbeJumpHere(v, j1);
         3042  +  sqlite3VdbeJumpHere(v, addr1);
  3043   3043     sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA_noB); VdbeCoverage(v);
  3044   3044     sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);
  3045   3045   
  3046   3046     /* Implement the main merge loop
  3047   3047     */
  3048   3048     sqlite3VdbeResolveLabel(v, labelCmpr);
  3049   3049     sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);
................................................................................
  5209   5209       if( db->mallocFailed ) goto select_end;
  5210   5210   
  5211   5211       /* Processing for aggregates with GROUP BY is very different and
  5212   5212       ** much more complex than aggregates without a GROUP BY.
  5213   5213       */
  5214   5214       if( pGroupBy ){
  5215   5215         KeyInfo *pKeyInfo;  /* Keying information for the group by clause */
  5216         -      int j1;             /* A-vs-B comparision jump */
         5216  +      int addr1;          /* A-vs-B comparision jump */
  5217   5217         int addrOutputRow;  /* Start of subroutine that outputs a result row */
  5218   5218         int regOutputRow;   /* Return address register for output subroutine */
  5219   5219         int addrSetAbort;   /* Set the abort flag and return */
  5220   5220         int addrTopOfLoop;  /* Top of the input loop */
  5221   5221         int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */
  5222   5222         int addrReset;      /* Subroutine for resetting the accumulator */
  5223   5223         int regReset;       /* Return address register for reset subroutine */
................................................................................
  5357   5357           }else{
  5358   5358             sAggInfo.directMode = 1;
  5359   5359             sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);
  5360   5360           }
  5361   5361         }
  5362   5362         sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr,
  5363   5363                             (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);
  5364         -      j1 = sqlite3VdbeCurrentAddr(v);
  5365         -      sqlite3VdbeAddOp3(v, OP_Jump, j1+1, 0, j1+1); VdbeCoverage(v);
         5364  +      addr1 = sqlite3VdbeCurrentAddr(v);
         5365  +      sqlite3VdbeAddOp3(v, OP_Jump, addr1+1, 0, addr1+1); VdbeCoverage(v);
  5366   5366   
  5367   5367         /* Generate code that runs whenever the GROUP BY changes.
  5368   5368         ** Changes in the GROUP BY are detected by the previous code
  5369   5369         ** block.  If there were no changes, this block is skipped.
  5370   5370         **
  5371   5371         ** This code copies current group by terms in b0,b1,b2,...
  5372   5372         ** over to a0,a1,a2.  It then calls the output subroutine
................................................................................
  5380   5380         VdbeComment((v, "check abort flag"));
  5381   5381         sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
  5382   5382         VdbeComment((v, "reset accumulator"));
  5383   5383   
  5384   5384         /* Update the aggregate accumulators based on the content of
  5385   5385         ** the current row
  5386   5386         */
  5387         -      sqlite3VdbeJumpHere(v, j1);
         5387  +      sqlite3VdbeJumpHere(v, addr1);
  5388   5388         updateAccumulator(pParse, &sAggInfo);
  5389   5389         sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
  5390   5390         VdbeComment((v, "indicate data in accumulator"));
  5391   5391   
  5392   5392         /* End of the loop
  5393   5393         */
  5394   5394         if( groupBySort ){

Changes to src/update.c.

   560    560         if( aXRef[i]<0 && i!=pTab->iPKey ){
   561    561           sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);
   562    562         }
   563    563       }
   564    564     }
   565    565   
   566    566     if( !isView ){
   567         -    int j1 = 0;           /* Address of jump instruction */
          567  +    int addr1 = 0;        /* Address of jump instruction */
   568    568       int bReplace = 0;     /* True if REPLACE conflict resolution might happen */
   569    569   
   570    570       /* Do constraint checks. */
   571    571       assert( regOldRowid>0 );
   572    572       sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
   573    573           regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace);
   574    574   
................................................................................
   576    576       if( hasFK ){
   577    577         sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
   578    578       }
   579    579   
   580    580       /* Delete the index entries associated with the current record.  */
   581    581       if( bReplace || chngKey ){
   582    582         if( pPk ){
   583         -        j1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);
          583  +        addr1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);
   584    584         }else{
   585         -        j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);
          585  +        addr1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);
   586    586         }
   587    587         VdbeCoverageNeverTaken(v);
   588    588       }
   589    589       sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);
   590    590   
   591    591       /* If changing the rowid value, or if there are foreign key constraints
   592    592       ** to process, delete the old record. Otherwise, add a noop OP_Delete
................................................................................
   602    602           OPFLAG_ISUPDATE | ((hasFK || chngKey || pPk!=0) ? 0 : OPFLAG_ISNOOP),
   603    603           regNewRowid
   604    604       );
   605    605       if( !pParse->nested ){
   606    606         sqlite3VdbeChangeP4(v, -1, (char*)pTab, P4_TABLE);
   607    607       }
   608    608       if( bReplace || chngKey ){
   609         -      sqlite3VdbeJumpHere(v, j1);
          609  +      sqlite3VdbeJumpHere(v, addr1);
   610    610       }
   611    611   
   612    612       if( hasFK ){
   613    613         sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);
   614    614       }
   615    615     
   616    616       /* Insert the new index entries and the new record. */

Changes to src/wherecode.c.

  1262   1262                   | WHERE_ONETABLE_ONLY
  1263   1263                   | WHERE_NO_AUTOINDEX;
  1264   1264       for(ii=0; ii<pOrWc->nTerm; ii++){
  1265   1265         WhereTerm *pOrTerm = &pOrWc->a[ii];
  1266   1266         if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
  1267   1267           WhereInfo *pSubWInfo;           /* Info for single OR-term scan */
  1268   1268           Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
  1269         -        int j1 = 0;                     /* Address of jump operation */
         1269  +        int jmp1 = 0;                   /* Address of jump operation */
  1270   1270           if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){
  1271   1271             pAndExpr->pLeft = pOrExpr;
  1272   1272             pOrExpr = pAndExpr;
  1273   1273           }
  1274   1274           /* Loop through table entries that match term pOrTerm. */
  1275   1275           WHERETRACE(0xffff, ("Subplan for OR-clause:\n"));
  1276   1276           pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
................................................................................
  1289   1289             ** row will be skipped in subsequent sub-WHERE clauses.
  1290   1290             */
  1291   1291             if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
  1292   1292               int r;
  1293   1293               int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
  1294   1294               if( HasRowid(pTab) ){
  1295   1295                 r = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, regRowid, 0);
  1296         -              j1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0, r,iSet);
         1296  +              jmp1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0,
         1297  +                                           r,iSet);
  1297   1298                 VdbeCoverage(v);
  1298   1299               }else{
  1299   1300                 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
  1300   1301                 int nPk = pPk->nKeyCol;
  1301   1302                 int iPk;
  1302   1303   
  1303   1304                 /* Read the PK into an array of temp registers. */
................................................................................
  1319   1320                 **
  1320   1321                 ** Use some of the same optimizations as OP_RowSetTest: If iSet
  1321   1322                 ** is zero, assume that the key cannot already be present in
  1322   1323                 ** the temp table. And if iSet is -1, assume that there is no 
  1323   1324                 ** need to insert the key into the temp table, as it will never 
  1324   1325                 ** be tested for.  */ 
  1325   1326                 if( iSet ){
  1326         -                j1 = sqlite3VdbeAddOp4Int(v, OP_Found, regRowset, 0, r, nPk);
         1327  +                jmp1 = sqlite3VdbeAddOp4Int(v, OP_Found, regRowset, 0, r, nPk);
  1327   1328                   VdbeCoverage(v);
  1328   1329                 }
  1329   1330                 if( iSet>=0 ){
  1330   1331                   sqlite3VdbeAddOp3(v, OP_MakeRecord, r, nPk, regRowid);
  1331   1332                   sqlite3VdbeAddOp3(v, OP_IdxInsert, regRowset, regRowid, 0);
  1332   1333                   if( iSet ) sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
  1333   1334                 }
................................................................................
  1338   1339             }
  1339   1340   
  1340   1341             /* Invoke the main loop body as a subroutine */
  1341   1342             sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
  1342   1343   
  1343   1344             /* Jump here (skipping the main loop body subroutine) if the
  1344   1345             ** current sub-WHERE row is a duplicate from prior sub-WHEREs. */
  1345         -          if( j1 ) sqlite3VdbeJumpHere(v, j1);
         1346  +          if( jmp1 ) sqlite3VdbeJumpHere(v, jmp1);
  1346   1347   
  1347   1348             /* The pSubWInfo->untestedTerms flag means that this OR term
  1348   1349             ** contained one or more AND term from a notReady table.  The
  1349   1350             ** terms from the notReady table could not be tested and will
  1350   1351             ** need to be tested later.
  1351   1352             */
  1352   1353             if( pSubWInfo->untestedTerms ) untestedTerms = 1;