/ Check-in [bbd2d0e1]
Login

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

Overview
Comment:Pull in all changes from the 3.19.0 release.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA3-256: bbd2d0e1400984c9fabb4df015981c09ad172139ffa33db5132951d4f1f6fc96
User & Date: drh 2017-05-22 19:24:01
Context
2017-05-25
17:36
Merge all fixes from the 3.19.2 release. check-in: 12964240 user: drh tags: apple-osx
2017-05-22
19:24
Pull in all changes from the 3.19.0 release. check-in: bbd2d0e1 user: drh tags: apple-osx
13:58
Version 3.19.0 check-in: 28a94eb2 user: drh tags: release, branch-3.19, version-3.19.0
2017-05-11
18:49
Merge recent enhancements from trunk. check-in: b55c0f14 user: drh tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.msc.

  1561   1561   $(SQLITE3DLL):	$(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP)
  1562   1562   	$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
  1563   1563   
  1564   1564   # <<block2>>
  1565   1565   sqlite3.def:	libsqlite3.lib
  1566   1566   	echo EXPORTS > sqlite3.def
  1567   1567   	dumpbin /all libsqlite3.lib \
  1568         -		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl include "^\s+1 _?(sqlite3(?:session|changeset)?_[^@]*)(?:@\d+)?$$" \1 \
         1568  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl include "^\s+1 _?(sqlite3(?:session|changeset|changegroup)?_[^@]*)(?:@\d+)?$$" \1 \
  1569   1569   		| sort >> sqlite3.def
  1570   1570   # <</block2>>
  1571   1571   
  1572   1572   $(SQLITE3EXE):	$(TOP)\src\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
  1573   1573   	$(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\src\shell.c $(SHELL_CORE_SRC) \
  1574   1574   		/link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
  1575   1575   

Changes to autoconf/Makefile.am.

     8      8   bin_PROGRAMS = sqlite3
     9      9   sqlite3_SOURCES = shell.c sqlite3.h
    10     10   EXTRA_sqlite3_SOURCES = sqlite3.c
    11     11   sqlite3_LDADD = @EXTRA_SHELL_OBJ@ @READLINE_LIBS@
    12     12   sqlite3_DEPENDENCIES = @EXTRA_SHELL_OBJ@
    13     13   sqlite3_CFLAGS = $(AM_CFLAGS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS
    14     14   
    15         -include_HEADERS = sqlite3.h sqlite3ext.h
           15  +include_HEADERS = sqlite3.h sqlite3ext.h msvc.h
    16     16   
    17     17   EXTRA_DIST = sqlite3.1 tea Makefile.msc sqlite3.rc README.txt Replace.cs
    18     18   pkgconfigdir = ${libdir}/pkgconfig
    19     19   pkgconfig_DATA = sqlite3.pc
    20     20   
    21     21   man_MANS = sqlite3.1

Changes to autoconf/Makefile.msc.

    17     17   #
    18     18   TOP = .
    19     19   
    20     20   
    21     21   # Set this non-0 to enable full warnings (-W4, etc) when compiling.
    22     22   #
    23     23   !IFNDEF USE_FULLWARN
    24         -USE_FULLWARN = 0
           24  +USE_FULLWARN = 1
    25     25   !ENDIF
    26     26   
    27     27   # Set this non-0 to enable treating warnings as errors (-WX, etc) when
    28     28   # compiling.
    29     29   #
    30     30   !IFNDEF USE_FATAL_WARN
    31     31   USE_FATAL_WARN = 0
................................................................................
   950    950   
   951    951   Replace.exe:
   952    952   	$(CSC) /target:exe $(TOP)\Replace.cs
   953    953   
   954    954   sqlite3.def:	Replace.exe $(LIBOBJ)
   955    955   	echo EXPORTS > sqlite3.def
   956    956   	dumpbin /all $(LIBOBJ) \
   957         -		| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
          957  +		| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
   958    958   		| sort >> sqlite3.def
   959    959   
   960    960   $(SQLITE3EXE):	$(TOP)\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
   961    961   	$(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\shell.c $(SHELL_CORE_SRC) \
   962    962   		/link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
   963    963   
   964    964   

Changes to ext/fts5/fts5_buffer.c.

    63     63   void sqlite3Fts5BufferAppendBlob(
    64     64     int *pRc,
    65     65     Fts5Buffer *pBuf, 
    66     66     u32 nData, 
    67     67     const u8 *pData
    68     68   ){
    69     69     assert_nc( *pRc || nData>=0 );
    70         -  if( fts5BufferGrow(pRc, pBuf, nData) ) return;
    71         -  memcpy(&pBuf->p[pBuf->n], pData, nData);
    72         -  pBuf->n += nData;
           70  +  if( nData ){
           71  +    if( fts5BufferGrow(pRc, pBuf, nData) ) return;
           72  +    memcpy(&pBuf->p[pBuf->n], pData, nData);
           73  +    pBuf->n += nData;
           74  +  }
    73     75   }
    74     76   
    75     77   /*
    76     78   ** Append the nul-terminated string zStr to the buffer pBuf. This function
    77     79   ** ensures that the byte following the buffer data is set to 0x00, even 
    78     80   ** though this byte is not included in the pBuf->n count.
    79     81   */
................................................................................
   242    244     return SQLITE_OK;
   243    245   }
   244    246   
   245    247   void *sqlite3Fts5MallocZero(int *pRc, int nByte){
   246    248     void *pRet = 0;
   247    249     if( *pRc==SQLITE_OK ){
   248    250       pRet = sqlite3_malloc(nByte);
   249         -    if( pRet==0 && nByte>0 ){
   250         -      *pRc = SQLITE_NOMEM;
          251  +    if( pRet==0 ){
          252  +      if( nByte>0 ) *pRc = SQLITE_NOMEM;
   251    253       }else{
   252    254         memset(pRet, 0, nByte);
   253    255       }
   254    256     }
   255    257     return pRet;
   256    258   }
   257    259   

Changes to ext/fts5/fts5_hash.c.

    32     32     int nSlot;                      /* Size of aSlot[] array */
    33     33     Fts5HashEntry *pScan;           /* Current ordered scan item */
    34     34     Fts5HashEntry **aSlot;          /* Array of hash slots */
    35     35   };
    36     36   
    37     37   /*
    38     38   ** Each entry in the hash table is represented by an object of the 
    39         -** following type. Each object, its key (zKey[]) and its current data
    40         -** are stored in a single memory allocation. The position list data 
    41         -** immediately follows the key data in memory.
           39  +** following type. Each object, its key (a nul-terminated string) and 
           40  +** its current data are stored in a single memory allocation. The 
           41  +** key immediately follows the object in memory. The position list
           42  +** data immediately follows the key data in memory.
    42     43   **
    43     44   ** The data that follows the key is in a similar, but not identical format
    44     45   ** to the doclist data stored in the database. It is:
    45     46   **
    46     47   **   * Rowid, as a varint
    47     48   **   * Position list, without 0x00 terminator.
    48     49   **   * Size of previous position list and rowid, as a 4 byte
................................................................................
    58     59   struct Fts5HashEntry {
    59     60     Fts5HashEntry *pHashNext;       /* Next hash entry with same hash-key */
    60     61     Fts5HashEntry *pScanNext;       /* Next entry in sorted order */
    61     62     
    62     63     int nAlloc;                     /* Total size of allocation */
    63     64     int iSzPoslist;                 /* Offset of space for 4-byte poslist size */
    64     65     int nData;                      /* Total bytes of data (incl. structure) */
    65         -  int nKey;                       /* Length of zKey[] in bytes */
           66  +  int nKey;                       /* Length of key in bytes */
    66     67     u8 bDel;                        /* Set delete-flag @ iSzPoslist */
    67     68     u8 bContent;                    /* Set content-flag (detail=none mode) */
    68     69     i16 iCol;                       /* Column of last value written */
    69     70     int iPos;                       /* Position of last value written */
    70     71     i64 iRowid;                     /* Rowid of last value written */
    71         -  char zKey[8];                   /* Nul-terminated entry key */
    72     72   };
    73     73   
    74     74   /*
    75         -** Size of Fts5HashEntry without the zKey[] array.
           75  +** Eqivalent to:
           76  +**
           77  +**   char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; }
    76     78   */
    77         -#define FTS5_HASHENTRYSIZE (sizeof(Fts5HashEntry)-8)
    78         -
           79  +#define fts5EntryKey(p) ( ((char *)(&(p)[1])) )
    79     80   
    80     81   
    81     82   /*
    82     83   ** Allocate a new hash table.
    83     84   */
    84     85   int sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte){
    85     86     int rc = SQLITE_OK;
................................................................................
   169    170     memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));
   170    171   
   171    172     for(i=0; i<pHash->nSlot; i++){
   172    173       while( apOld[i] ){
   173    174         int iHash;
   174    175         Fts5HashEntry *p = apOld[i];
   175    176         apOld[i] = p->pHashNext;
   176         -      iHash = fts5HashKey(nNew, (u8*)p->zKey, (int)strlen(p->zKey));
          177  +      iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), strlen(fts5EntryKey(p)));
   177    178         p->pHashNext = apNew[iHash];
   178    179         apNew[iHash] = p;
   179    180       }
   180    181     }
   181    182   
   182    183     sqlite3_free(apOld);
   183    184     pHash->nSlot = nNew;
................................................................................
   240    241     int bNew;                       /* If non-delete entry should be written */
   241    242     
   242    243     bNew = (pHash->eDetail==FTS5_DETAIL_FULL);
   243    244   
   244    245     /* Attempt to locate an existing hash entry */
   245    246     iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);
   246    247     for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
   247         -    if( p->zKey[0]==bByte 
          248  +    char *zKey = fts5EntryKey(p);
          249  +    if( zKey[0]==bByte 
   248    250        && p->nKey==nToken
   249         -     && memcmp(&p->zKey[1], pToken, nToken)==0 
          251  +     && memcmp(&zKey[1], pToken, nToken)==0 
   250    252       ){
   251    253         break;
   252    254       }
   253    255     }
   254    256   
   255    257     /* If an existing hash entry cannot be found, create a new one. */
   256    258     if( p==0 ){
   257    259       /* Figure out how much space to allocate */
   258         -    int nByte = FTS5_HASHENTRYSIZE + (nToken+1) + 1 + 64;
          260  +    char *zKey;
          261  +    int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
   259    262       if( nByte<128 ) nByte = 128;
   260    263   
   261    264       /* Grow the Fts5Hash.aSlot[] array if necessary. */
   262    265       if( (pHash->nEntry*2)>=pHash->nSlot ){
   263    266         int rc = fts5HashResize(pHash);
   264    267         if( rc!=SQLITE_OK ) return rc;
   265    268         iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);
   266    269       }
   267    270   
   268    271       /* Allocate new Fts5HashEntry and add it to the hash table. */
   269    272       p = (Fts5HashEntry*)sqlite3_malloc(nByte);
   270    273       if( !p ) return SQLITE_NOMEM;
   271         -    memset(p, 0, FTS5_HASHENTRYSIZE);
          274  +    memset(p, 0, sizeof(Fts5HashEntry));
   272    275       p->nAlloc = nByte;
   273         -    p->zKey[0] = bByte;
   274         -    memcpy(&p->zKey[1], pToken, nToken);
   275         -    assert( iHash==fts5HashKey(pHash->nSlot, (u8*)p->zKey, nToken+1) );
          276  +    zKey = fts5EntryKey(p);
          277  +    zKey[0] = bByte;
          278  +    memcpy(&zKey[1], pToken, nToken);
          279  +    assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );
   276    280       p->nKey = nToken;
   277         -    p->zKey[nToken+1] = '\0';
   278         -    p->nData = nToken+1 + 1 + FTS5_HASHENTRYSIZE;
          281  +    zKey[nToken+1] = '\0';
          282  +    p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry);
   279    283       p->pHashNext = pHash->aSlot[iHash];
   280    284       pHash->aSlot[iHash] = p;
   281    285       pHash->nEntry++;
   282    286   
   283    287       /* Add the first rowid field to the hash-entry */
   284    288       p->nData += sqlite3Fts5PutVarint(&((u8*)p)[p->nData], iRowid);
   285    289       p->iRowid = iRowid;
................................................................................
   389    393         *ppOut = p2;
   390    394         p2 = 0;
   391    395       }else if( p2==0 ){
   392    396         *ppOut = p1;
   393    397         p1 = 0;
   394    398       }else{
   395    399         int i = 0;
   396         -      while( p1->zKey[i]==p2->zKey[i] ) i++;
          400  +      char *zKey1 = fts5EntryKey(p1);
          401  +      char *zKey2 = fts5EntryKey(p2);
          402  +      while( zKey1[i]==zKey2[i] ) i++;
   397    403   
   398         -      if( ((u8)p1->zKey[i])>((u8)p2->zKey[i]) ){
          404  +      if( ((u8)zKey1[i])>((u8)zKey2[i]) ){
   399    405           /* p2 is smaller */
   400    406           *ppOut = p2;
   401    407           ppOut = &p2->pScanNext;
   402    408           p2 = p2->pScanNext;
   403    409         }else{
   404    410           /* p1 is smaller */
   405    411           *ppOut = p1;
................................................................................
   434    440     ap = sqlite3_malloc(sizeof(Fts5HashEntry*) * nMergeSlot);
   435    441     if( !ap ) return SQLITE_NOMEM;
   436    442     memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
   437    443   
   438    444     for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
   439    445       Fts5HashEntry *pIter;
   440    446       for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
   441         -      if( pTerm==0 || 0==memcmp(pIter->zKey, pTerm, nTerm) ){
          447  +      if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){
   442    448           Fts5HashEntry *pEntry = pIter;
   443    449           pEntry->pScanNext = 0;
   444    450           for(i=0; ap[i]; i++){
   445    451             pEntry = fts5HashEntryMerge(pEntry, ap[i]);
   446    452             ap[i] = 0;
   447    453           }
   448    454           ap[i] = pEntry;
................................................................................
   467    473   int sqlite3Fts5HashQuery(
   468    474     Fts5Hash *pHash,                /* Hash table to query */
   469    475     const char *pTerm, int nTerm,   /* Query term */
   470    476     const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */
   471    477     int *pnDoclist                  /* OUT: Size of doclist in bytes */
   472    478   ){
   473    479     unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
          480  +  char *zKey;
   474    481     Fts5HashEntry *p;
   475    482   
   476    483     for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
   477         -    if( memcmp(p->zKey, pTerm, nTerm)==0 && p->zKey[nTerm]==0 ) break;
          484  +    zKey = fts5EntryKey(p);
          485  +    if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
   478    486     }
   479    487   
   480    488     if( p ){
   481    489       fts5HashAddPoslistSize(pHash, p);
   482         -    *ppDoclist = (const u8*)&p->zKey[nTerm+1];
   483         -    *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
          490  +    *ppDoclist = (const u8*)&zKey[nTerm+1];
          491  +    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
   484    492     }else{
   485    493       *ppDoclist = 0;
   486    494       *pnDoclist = 0;
   487    495     }
   488    496   
   489    497     return SQLITE_OK;
   490    498   }
................................................................................
   509    517     Fts5Hash *pHash,
   510    518     const char **pzTerm,            /* OUT: term (nul-terminated) */
   511    519     const u8 **ppDoclist,           /* OUT: pointer to doclist */
   512    520     int *pnDoclist                  /* OUT: size of doclist in bytes */
   513    521   ){
   514    522     Fts5HashEntry *p;
   515    523     if( (p = pHash->pScan) ){
   516         -    int nTerm = (int)strlen(p->zKey);
          524  +    char *zKey = fts5EntryKey(p);
          525  +    int nTerm = (int)strlen(zKey);
   517    526       fts5HashAddPoslistSize(pHash, p);
   518         -    *pzTerm = p->zKey;
   519         -    *ppDoclist = (const u8*)&p->zKey[nTerm+1];
   520         -    *pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
          527  +    *pzTerm = zKey;
          528  +    *ppDoclist = (const u8*)&zKey[nTerm+1];
          529  +    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
   521    530     }else{
   522    531       *pzTerm = 0;
   523    532       *ppDoclist = 0;
   524    533       *pnDoclist = 0;
   525    534     }
   526    535   }
   527    536   

Changes to ext/fts5/fts5_index.c.

  5089   5089       }
  5090   5090       fts5MultiIterFree(p1);
  5091   5091   
  5092   5092       pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
  5093   5093       if( pData ){
  5094   5094         pData->p = (u8*)&pData[1];
  5095   5095         pData->nn = pData->szLeaf = doclist.n;
  5096         -      memcpy(pData->p, doclist.p, doclist.n);
         5096  +      if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);
  5097   5097         fts5MultiIterNew2(p, pData, bDesc, ppIter);
  5098   5098       }
  5099   5099       fts5BufferFree(&doclist);
  5100   5100     }
  5101   5101   
  5102   5102     fts5StructureRelease(pStruct);
  5103   5103     sqlite3_free(aBuf);
................................................................................
  5328   5328     Fts5Buffer buf = {0, 0, 0};
  5329   5329   
  5330   5330     /* If the QUERY_SCAN flag is set, all other flags must be clear. */
  5331   5331     assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN );
  5332   5332   
  5333   5333     if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
  5334   5334       int iIdx = 0;                 /* Index to search */
  5335         -    memcpy(&buf.p[1], pToken, nToken);
         5335  +    if( nToken ) memcpy(&buf.p[1], pToken, nToken);
  5336   5336   
  5337   5337       /* Figure out which index to search and set iIdx accordingly. If this
  5338   5338       ** is a prefix query for which there is no prefix index, set iIdx to
  5339   5339       ** greater than pConfig->nPrefix to indicate that the query will be
  5340   5340       ** satisfied by scanning multiple terms in the main index.
  5341   5341       **
  5342   5342       ** If the QUERY_TEST_NOIDX flag was specified, then this must be a
................................................................................
  5377   5377         if( p->rc==SQLITE_OK ){
  5378   5378           Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];
  5379   5379           if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);
  5380   5380         }
  5381   5381       }
  5382   5382   
  5383   5383       if( p->rc ){
  5384         -      sqlite3Fts5IterClose(&pRet->base);
         5384  +      sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
  5385   5385         pRet = 0;
  5386   5386         fts5CloseReader(p);
  5387   5387       }
  5388   5388   
  5389   5389       *ppIter = &pRet->base;
  5390   5390       sqlite3Fts5BufferFree(&buf);
  5391   5391     }

Changes to src/expr.c.

   348    348     }else if( op==TK_SELECT ){
   349    349       return pExpr->x.pSelect->pEList->nExpr;
   350    350     }else{
   351    351       return 1;
   352    352     }
   353    353   }
   354    354   
   355         -#ifndef SQLITE_OMIT_SUBQUERY
   356    355   /*
   357    356   ** Return a pointer to a subexpression of pVector that is the i-th
   358    357   ** column of the vector (numbered starting with 0).  The caller must
   359    358   ** ensure that i is within range.
   360    359   **
   361    360   ** If pVector is really a scalar (and "scalar" here includes subqueries
   362    361   ** that return a single column!) then return pVector unmodified.
................................................................................
   376    375         return pVector->x.pSelect->pEList->a[i].pExpr;
   377    376       }else{
   378    377         return pVector->x.pList->a[i].pExpr;
   379    378       }
   380    379     }
   381    380     return pVector;
   382    381   }
   383         -#endif /* !defined(SQLITE_OMIT_SUBQUERY) */
   384    382   
   385         -#ifndef SQLITE_OMIT_SUBQUERY
   386    383   /*
   387    384   ** Compute and return a new Expr object which when passed to
   388    385   ** sqlite3ExprCode() will generate all necessary code to compute
   389    386   ** the iField-th column of the vector expression pVector.
   390    387   **
   391    388   ** It is ok for pVector to be a scalar (as long as iField==0).  
   392    389   ** In that case, this routine works like sqlite3ExprDup().
................................................................................
   436    433       assert( pRet==0 || pRet->iTable==0 );
   437    434     }else{
   438    435       if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
   439    436       pRet = sqlite3ExprDup(pParse->db, pVector, 0);
   440    437     }
   441    438     return pRet;
   442    439   }
   443         -#endif /* !define(SQLITE_OMIT_SUBQUERY) */
   444    440   
   445    441   /*
   446    442   ** If expression pExpr is of type TK_SELECT, generate code to evaluate
   447    443   ** it. Return the register in which the result is stored (or, if the 
   448    444   ** sub-select returns more than one column, the first in an array
   449    445   ** of registers in which the result is stored).
   450    446   **
................................................................................
  3407   3403     int iResult;
  3408   3404     int nResult = sqlite3ExprVectorSize(p);
  3409   3405     if( nResult==1 ){
  3410   3406       iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);
  3411   3407     }else{
  3412   3408       *piFreeable = 0;
  3413   3409       if( p->op==TK_SELECT ){
         3410  +#if SQLITE_OMIT_SUBQUERY
         3411  +      iResult = 0;
         3412  +#else
  3414   3413         iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
         3414  +#endif
  3415   3415       }else{
  3416   3416         int i;
  3417   3417         iResult = pParse->nMem+1;
  3418   3418         pParse->nMem += nResult;
  3419   3419         for(i=0; i<nResult; i++){
  3420   3420           sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult);
  3421   3421         }

Changes to src/vdbe.c.

  4103   4103         assert( (r.aMem[ii].flags & MEM_Zero)==0 || r.aMem[ii].n==0 );
  4104   4104         if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]);
  4105   4105       }
  4106   4106   #endif
  4107   4107       pIdxKey = &r;
  4108   4108       pFree = 0;
  4109   4109     }else{
         4110  +    assert( pIn3->flags & MEM_Blob );
         4111  +    rc = ExpandBlob(pIn3);
         4112  +    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
         4113  +    if( rc ) goto no_mem;
  4110   4114       pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo);
  4111   4115       if( pIdxKey==0 ) goto no_mem;
  4112         -    assert( pIn3->flags & MEM_Blob );
  4113         -    (void)ExpandBlob(pIn3);
  4114   4116       sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
  4115   4117     }
  4116   4118     pIdxKey->default_rc = 0;
  4117   4119     takeJump = 0;
  4118   4120     if( pOp->opcode==OP_NoConflict ){
  4119   4121       /* For the OP_NoConflict opcode, take the jump if any of the
  4120   4122       ** input fields are NULL, since any key with a NULL will not

Changes to test/auth.test.

  2520   2520     execsql {SELECT t6.a FROM t6, t7}
  2521   2521     set ::authargs
  2522   2522   } [list \
  2523   2523     SQLITE_SELECT {} {} {} {}          \
  2524   2524     SQLITE_READ t6 a main {}           \
  2525   2525     SQLITE_READ t7 {} {} {}            \
  2526   2526     ]
         2527  +
         2528  +# Test also that if SQLITE_DENY is returned from an SQLITE_READ authorizer 
         2529  +# invocation with no column name specified, compilation fails.
         2530  +#
         2531  +set ::authargs [list]
         2532  +proc auth {op a b c d} {
         2533  +  lappend ::authargs $op $a $b $c $d
         2534  +  if {$op == "SQLITE_READ"} { return "SQLITE_DENY" }
         2535  +  return "SQLITE_OK"
         2536  +}
         2537  +set ::authargs [list]
         2538  +do_catchsql_test auth-8.3 {
         2539  +  SELECT count(*) FROM t7
         2540  +} {1 {not authorized}}
         2541  +do_test auth-8.4 {
         2542  +  set ::authargs
         2543  +} [list \
         2544  +  SQLITE_SELECT {} {} {} {}          \
         2545  +  SQLITE_FUNCTION {} count {} {}     \
         2546  +  SQLITE_READ t7 {} {} {}            \
         2547  +]
         2548  +
  2527   2549   
  2528   2550   rename proc {}
  2529   2551   rename proc_real proc
  2530   2552   finish_test

Changes to tool/mkautoconfamal.sh.

    47     47   rm -rf $TMPSPACE
    48     48   cp -R $TOP/autoconf       $TMPSPACE
    49     49   cp sqlite3.c              $TMPSPACE
    50     50   cp sqlite3.h              $TMPSPACE
    51     51   cp sqlite3ext.h           $TMPSPACE
    52     52   cp $TOP/sqlite3.1         $TMPSPACE
    53     53   cp $TOP/sqlite3.pc.in     $TMPSPACE
           54  +cp $TOP/src/msvc.h        $TMPSPACE
    54     55   cp $TOP/src/shell.c       $TMPSPACE
    55     56   cp $TOP/src/sqlite3.rc    $TMPSPACE
    56     57   cp $TOP/tool/Replace.cs   $TMPSPACE
    57     58   
    58     59   cat $TMPSPACE/configure.ac |
    59     60   sed "s/--SQLITE-VERSION--/$VERSION/" > $TMPSPACE/tmp
    60     61   mv $TMPSPACE/tmp $TMPSPACE/configure.ac

Changes to tool/mkmsvcmin.tcl.

    79     79   set blocks(2) [string trimleft [string map [list \\\\ \\] {
    80     80   Replace.exe:
    81     81   	$(CSC) /target:exe $(TOP)\Replace.cs
    82     82   
    83     83   sqlite3.def:	Replace.exe $(LIBOBJ)
    84     84   	echo EXPORTS > sqlite3.def
    85     85   	dumpbin /all $(LIBOBJ) \\
    86         -		| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \\
           86  +		| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \\
    87     87   		| sort >> sqlite3.def
    88     88   }]]
    89     89   
    90     90   set data "#### DO NOT EDIT ####\n"
    91     91   append data "# This makefile is automatically "
    92     92   append data "generated from the [file tail $fromFileName] at\n"
    93     93   append data "# the root of the canonical SQLite source tree (not the\n"

Changes to tool/mksqlite3h.tcl.

    77     77   
    78     78   set declpattern2 \
    79     79       {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3session_[_a-zA-Z0-9]+)(\(.*)$}
    80     80   
    81     81   set declpattern3 \
    82     82       {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3changeset_[_a-zA-Z0-9]+)(\(.*)$}
    83     83   
           84  +set declpattern4 \
           85  +    {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3changegroup_[_a-zA-Z0-9]+)(\(.*)$}
           86  +
    84     87   # Force the output to use unix line endings, even on Windows.
    85     88   fconfigure stdout -translation lf
    86     89   
    87     90   set filelist [subst {
    88     91     $TOP/src/sqlite.h.in
    89     92     $TOP/ext/rtree/sqlite3rtree.h
    90     93     $TOP/ext/session/sqlite3session.h
................................................................................
   125    128       regsub -- --SOURCE-ID--      $line "$zDate $zUuid" line
   126    129   
   127    130       if {[regexp $varpattern $line] && ![regexp {^ *typedef} $line]} {
   128    131         set line "SQLITE_API $line"
   129    132       } else {
   130    133         if {[regexp $declpattern1 $line all rettype funcname rest] || \
   131    134             [regexp $declpattern2 $line all rettype funcname rest] || \
   132         -          [regexp $declpattern3 $line all rettype funcname rest]} {
          135  +          [regexp $declpattern3 $line all rettype funcname rest] || \
          136  +          [regexp $declpattern4 $line all rettype funcname rest]} {
   133    137           set line SQLITE_API
   134    138           append line " " [string trim $rettype]
   135    139           if {[string index $rettype end] ne "*"} {
   136    140             append line " "
   137    141           }
   138    142           if {$useapicall} {
   139    143             if {[lsearch -exact $cdecllist $funcname] >= 0} {

Changes to tool/omittest.tcl.

     1         -
     2         -set rcsid {$Id: omittest.tcl,v 1.8 2008/10/13 15:35:09 drh Exp $}
     3         -
     4      1   # Documentation for this script. This may be output to stderr
     5      2   # if the script is invoked incorrectly.
     6      3   set ::USAGE_MESSAGE {
     7      4   This Tcl script is used to test the various compile time options 
     8      5   available for omitting code (the SQLITE_OMIT_xxx options). It
     9      6   should be invoked as follows:
    10      7   
................................................................................
   130    127     } else {
   131    128       set ::MAKEFILE ./Makefile.linux-gcc     ;# Default value
   132    129     }
   133    130     set ::SKIP_RUN 0                          ;# Default to attempt test
   134    131     set ::TARGET testfixture                  ;# Default thing to build
   135    132   
   136    133     for {set i 0} {$i < [llength $argv]} {incr i} {
   137         -    switch -- [lindex $argv $i] {
   138         -      -makefile {
          134  +    switch -regexp -- [lindex $argv $i] {
          135  +      -{1,2}makefile {
   139    136           incr i
   140    137           set ::MAKEFILE [lindex $argv $i]
   141    138         }
   142    139     
   143         -      -nmake {
          140  +      -{1,2}nmake {
   144    141           set ::MAKEBIN nmake
   145    142           set ::MAKEFILE ./Makefile.msc
   146    143         }
   147    144   
   148         -      -target {
          145  +      -{1,2}target {
   149    146           incr i
   150    147           set ::TARGET [lindex $argv $i]
   151    148         }
   152    149   
   153         -      -skip_run {
          150  +      -{1,2}skip_run {
   154    151           set ::SKIP_RUN 1
   155    152         }
          153  +
          154  +      -{1,2}help {
          155  +        puts $::USAGE_MESSAGE
          156  +        exit
          157  +      }
          158  +
          159  +      -.* {
          160  +        puts stderr "Unknown option: [lindex $argv i]"
          161  +        puts stderr $::USAGE_MESSAGE
          162  +        exit 1
          163  +      }
   156    164   
   157    165         default {
   158    166           if {[info exists ::SYMBOL]} {
   159    167             puts stderr [string trim $::USAGE_MESSAGE]
   160    168             exit -1
   161    169           }
   162    170           set ::SYMBOL [lindex $argv $i]

Changes to tool/warnings.sh.

     1      1   #/bin/sh
     2      2   #
     3      3   # Run this script in a directory with a working makefile to check for 
     4      4   # compiler warnings in SQLite.
     5      5   #
     6      6   
     7         -# Use these for testing on Linux and Mac OSX:
     8         -WARNING_OPTS="-Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long"
     9         -WARNING_ANDROID_OPTS="-Wshadow -Wall -Wextra"
    10         -
    11         -# Use these for testing on OpenBSD:
    12         -# WARNING_OPTS=-Wall
    13         -# WARNING_ANDROID_OPTS=-Wall
            7  +if uname | grep -i openbsd ; then
            8  +  # Use these for testing on OpenBSD:
            9  +  WARNING_OPTS=-Wall
           10  +  WARNING_ANDROID_OPTS=-Wall
           11  +else
           12  +  # Use these for testing on Linux and Mac OSX:
           13  +  WARNING_OPTS="-Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long"
           14  +  WARNING_ANDROID_OPTS="-Wshadow -Wall -Wextra"
           15  +fi
    14     16   
    15     17   rm -f sqlite3.c
    16     18   make sqlite3.c
    17     19   echo '********** No optimizations.  Includes FTS4/5, RTREE, JSON1 ***'
    18     20   echo '**********    ' Options: $WARNING_OPTS
    19     21   gcc -c $WARNING_OPTS -std=c89 \
    20     22         -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \