/ Check-in [bc9b9cd0]
Login

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

Overview
Comment:Merge in latest trunk changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1:bc9b9cd0589c4a51ece2e4657d622a04fc203315
User & Date: dan 2012-08-31 14:10:24
Context
2012-09-28
10:57
Merge the latest trunk changes (PRAGMA busy_timeout and the ORDER BY query planner enhancements) into the apple-osx branch. check-in: 6a5c59dd user: drh tags: apple-osx
2012-08-31
14:10
Merge in latest trunk changes. check-in: bc9b9cd0 user: dan tags: apple-osx
12:31
Changes for ERROR_PATH_NOT_FOUND in addition to ERROR_FILE_NOT_FOUND in winAccess(). check-in: 527340ab user: drh tags: trunk
2012-08-25
01:38
Merge all the latest trunk changes into the apple-osx branch. check-in: 6723add4 user: drh tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.msc.

    14     14   # Set this non-0 to use the International Components for Unicode (ICU).
    15     15   #
    16     16   USE_ICU = 0
    17     17   
    18     18   # Set this non-0 to dynamically link to the MSVC runtime library.
    19     19   #
    20     20   USE_CRT_DLL = 0
           21  +
           22  +# Set this non-0 to attempt setting the native compiler automatically
           23  +# for cross-compiling the command line tools needed during the compilation
           24  +# process.
           25  +#
           26  +XCOMPILE = 0
    21     27   
    22     28   # Set this non-0 to use the native libraries paths for cross-compiling
    23     29   # the command line tools needed during the compilation process.
    24     30   #
    25     31   USE_NATIVE_LIBPATHS = 0
    26     32   
    27     33   # Set this non-0 to compile binaries suitable for the WinRT environment.
................................................................................
    79     85   # Check for the command macro NCC.  This should point to the compiler binary
    80     86   # for the platform the compilation process is taking place on.  If it is not
    81     87   # defined, simply define it to have the same value as the CC macro.  When
    82     88   # cross-compiling, it is suggested that this macro be modified via the command
    83     89   # line (since nmake itself does not provide a built-in method to guess it).
    84     90   # For example, to use the x86 compiler when cross-compiling for x64, a command
    85     91   # line similar to the following could be used (all on one line):
           92  +#
           93  +#     nmake /f Makefile.msc sqlite3.dll
           94  +#           XCOMPILE=1 USE_NATIVE_LIBPATHS=1
           95  +#
           96  +# Alternatively, the full path and file name to the compiler binary for the
           97  +# platform the compilation process is taking place may be specified (all on
           98  +# one line):
    86     99   #
    87    100   #     nmake /f Makefile.msc sqlite3.dll
    88    101   #           "NCC=""%VCINSTALLDIR%\bin\cl.exe"""
    89    102   #           USE_NATIVE_LIBPATHS=1
    90    103   #
    91    104   !IFDEF NCC
    92    105   NCC = $(NCC:\\=\)
          106  +!ELSEIF $(XCOMPILE)!=0
          107  +NCC = "$(VCINSTALLDIR)\bin\cl.exe"
          108  +NCC = $(NCC:\\=\)
    93    109   !ELSE
    94    110   NCC = $(CC)
    95    111   !ENDIF
    96    112   
    97    113   # Check for the MSVC runtime library path macro.  Othertise, this
    98    114   # value will default to the 'lib' directory underneath the MSVC
    99    115   # installation directory.

Changes to doc/lemon.html.

   477    477        of the shift.  No parsing conflict is reported.
   478    478   <li> If the precedence of the token it be shifted is less than the
   479    479        precedence of the rule to reduce, then resolve in favor of the
   480    480        reduce action.  No parsing conflict is reported.
   481    481   <li> If the precedences are the same and the shift token is
   482    482        right-associative, then resolve in favor of the shift.
   483    483        No parsing conflict is reported.
   484         -<li> If the precedences are the same the the shift token is
          484  +<li> If the precedences are the same the shift token is
   485    485        left-associative, then resolve in favor of the reduce.
   486    486        No parsing conflict is reported.
   487    487   <li> Otherwise, resolve the conflict by doing the shift and
   488    488        report the parsing conflict.
   489    489   </ul>
   490    490   Reduce-reduce conflicts are resolved this way:
   491    491   <ul>

Changes to doc/pager-invariants.txt.

    40     40        being deleted, truncated, or zeroed.
    41     41    
    42     42    (6) If a master journal file is used, then all writes to the database file
    43     43        are synced prior to the master journal being deleted.
    44     44    
    45     45    *** Definition: Two databases (or the same database at two points it time)
    46     46        are said to be "logically equivalent" if they give the same answer to
    47         -     all queries.  Note in particular the the content of freelist leaf
           47  +     all queries.  Note in particular the content of freelist leaf
    48     48        pages can be changed arbitarily without effecting the logical equivalence
    49     49        of the database.
    50     50    
    51     51    (7) At any time, if any subset, including the empty set and the total set,
    52     52        of the unsynced changes to a rollback journal are removed and the 
    53     53        journal is rolled back, the resulting database file will be logical
    54     54        equivalent to the database file at the beginning of the transaction.

Changes to ext/fts2/fts2.c.

  5047   5047   */
  5048   5048   /* TODO(shess) This "solution" is not satisfactory.  Really, there
  5049   5049   ** should be check-in function for all statement handles which
  5050   5050   ** arranges to call sqlite3_reset().  This most likely will require
  5051   5051   ** modification to control flow all over the place, though, so for now
  5052   5052   ** just punt.
  5053   5053   **
  5054         -** Note the the current system assumes that segment merges will run to
         5054  +** Note the current system assumes that segment merges will run to
  5055   5055   ** completion, which is why this particular probably hasn't arisen in
  5056   5056   ** this case.  Probably a brittle assumption.
  5057   5057   */
  5058   5058   static int leavesReaderReset(LeavesReader *pReader){
  5059   5059     return sqlite3_reset(pReader->pStmt);
  5060   5060   }
  5061   5061   

Changes to ext/fts3/fts3_write.c.

  2965   2965     assert( iIndex>=0 && iIndex<p->nIndex );
  2966   2966   
  2967   2967     rc = sqlite3Fts3SegReaderCursor(p, iLangid, iIndex, iLevel, 0, 0, 1, 0, &csr);
  2968   2968     if( rc!=SQLITE_OK || csr.nSegment==0 ) goto finished;
  2969   2969   
  2970   2970     if( iLevel==FTS3_SEGCURSOR_ALL ){
  2971   2971       /* This call is to merge all segments in the database to a single
  2972         -    ** segment. The level of the new segment is equal to the the numerically 
         2972  +    ** segment. The level of the new segment is equal to the numerically
  2973   2973       ** greatest segment level currently present in the database for this
  2974   2974       ** index. The idx of the new segment is always 0.  */
  2975   2975       if( csr.nSegment==1 ){
  2976   2976         rc = SQLITE_DONE;
  2977   2977         goto finished;
  2978   2978       }
  2979   2979       rc = fts3SegmentMaxLevel(p, iLangid, iIndex, &iNewLevel);
................................................................................
  3595   3595           memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);
  3596   3596           pBlk->n += nSuffix;
  3597   3597   
  3598   3598           memcpy(pNode->key.a, zTerm, nTerm);
  3599   3599           pNode->key.n = nTerm;
  3600   3600         }
  3601   3601       }else{
  3602         -      /* Otherwise, flush the the current node of layer iLayer to disk.
         3602  +      /* Otherwise, flush the current node of layer iLayer to disk.
  3603   3603         ** Then allocate a new, empty sibling node. The key will be written
  3604   3604         ** into the parent of this node. */
  3605   3605         rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
  3606   3606   
  3607   3607         assert( pNode->block.nAlloc>=p->nNodeSize );
  3608   3608         pNode->block.a[0] = (char)iLayer;
  3609   3609         pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);

Changes to src/btree.c.

  6106   6106     szCell = (u16*)&apCell[nMaxCells];
  6107   6107     aSpace1 = (u8*)&szCell[nMaxCells];
  6108   6108     assert( EIGHT_BYTE_ALIGNMENT(aSpace1) );
  6109   6109   
  6110   6110     /*
  6111   6111     ** Load pointers to all cells on sibling pages and the divider cells
  6112   6112     ** into the local apCell[] array.  Make copies of the divider cells
  6113         -  ** into space obtained from aSpace1[] and remove the the divider Cells
         6113  +  ** into space obtained from aSpace1[] and remove the divider cells
  6114   6114     ** from pParent.
  6115   6115     **
  6116   6116     ** If the siblings are on leaf pages, then the child pointers of the
  6117   6117     ** divider cells are stripped from the cells before they are copied
  6118   6118     ** into aSpace1[].  In this way, all cells in apCell[] are without
  6119   6119     ** child pointers.  If siblings are not leaves, then all cell in
  6120   6120     ** apCell[] include child pointers.  Either way, all cells in apCell[]

Changes to src/build.c.

  2532   2532       */
  2533   2533       assert( pName1 && pName2 );
  2534   2534       iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
  2535   2535       if( iDb<0 ) goto exit_create_index;
  2536   2536       assert( pName && pName->z );
  2537   2537   
  2538   2538   #ifndef SQLITE_OMIT_TEMPDB
  2539         -    /* If the index name was unqualified, check if the the table
         2539  +    /* If the index name was unqualified, check if the table
  2540   2540       ** is a temp table. If so, set the database to 1. Do not do this
  2541   2541       ** if initialising a database schema.
  2542   2542       */
  2543   2543       if( !db->init.busy ){
  2544   2544         pTab = sqlite3SrcListLookup(pParse, pTblName);
  2545   2545         if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){
  2546   2546           iDb = 1;

Changes to src/insert.c.

  1267   1267           sqlite3HaltConstraint(
  1268   1268             pParse, onError, "PRIMARY KEY must be unique", P4_STATIC);
  1269   1269           break;
  1270   1270         }
  1271   1271         case OE_Replace: {
  1272   1272           /* If there are DELETE triggers on this table and the
  1273   1273           ** recursive-triggers flag is set, call GenerateRowDelete() to
  1274         -        ** remove the conflicting row from the the table. This will fire
         1274  +        ** remove the conflicting row from the table. This will fire
  1275   1275           ** the triggers and remove both the table and index b-tree entries.
  1276   1276           **
  1277   1277           ** Otherwise, if there are no triggers or the recursive-triggers
  1278   1278           ** flag is not set, but the table has one or more indexes, call 
  1279   1279           ** GenerateRowIndexDelete(). This removes the index b-tree entries 
  1280   1280           ** only. The table b-tree entry will be replaced by the new entry 
  1281   1281           ** when it is inserted.  

Changes to src/main.c.

  2229   2229     sqlite3 *db
  2230   2230   ){
  2231   2231     char *envprofile = getenv("SQLITE_AUTO_PROFILE");
  2232   2232     
  2233   2233     if( envprofile!=NULL ){
  2234   2234       int where = 0;
  2235   2235       if( !strncasecmp("1", envprofile, 1) ){
  2236         -      if( isatty(STDERR_FILENO) ){
         2236  +      if( isatty(2) ){
  2237   2237           where = SQLITE_AUTOLOGGING_STDERR;
  2238   2238         }else{
  2239   2239           where = SQLITE_AUTOLOGGING_SYSLOG;
  2240   2240         }
  2241   2241       } else if( !strncasecmp("stderr", envprofile, 6) ){
  2242   2242         where = SQLITE_AUTOLOGGING_STDERR;
  2243   2243       } else if( !strncasecmp("syslog", envprofile, 6) ){
................................................................................
  2250   2250         sqlite3_profile(db, _sqlite_auto_profile_syslog, db);
  2251   2251       }
  2252   2252     }
  2253   2253     char *envtrace = getenv("SQLITE_AUTO_TRACE");
  2254   2254     if( envtrace!=NULL ){
  2255   2255       int where = 0;
  2256   2256       if( !strncasecmp("1", envtrace, 1) ){
  2257         -      if( isatty(STDERR_FILENO) ){
         2257  +      if( isatty(2) ){
  2258   2258           where = SQLITE_AUTOLOGGING_STDERR;
  2259   2259         }else{
  2260   2260           where = SQLITE_AUTOLOGGING_SYSLOG;
  2261   2261         }
  2262   2262       } else if( !strncasecmp("stderr", envtrace, 6) ){
  2263   2263         where = SQLITE_AUTOLOGGING_STDERR;
  2264   2264       } else if( !strncasecmp("syslog", envtrace, 6) ){

Changes to src/os_unix.c.

  1343   1343   ** set. It logs a message using sqlite3_log() containing the current value of
  1344   1344   ** errno and, if possible, the human-readable equivalent from strerror() or
  1345   1345   ** strerror_r().
  1346   1346   **
  1347   1347   ** The first argument passed to the macro should be the error code that
  1348   1348   ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). 
  1349   1349   ** The two subsequent arguments should be the name of the OS function that
  1350         -** failed (e.g. "unlink", "open") and the the associated file-system path,
         1350  +** failed (e.g. "unlink", "open") and the associated file-system path,
  1351   1351   ** if any.
  1352   1352   */
  1353   1353   #define unixLogError(a,b,c)     unixLogErrorAtLine(a,b,c,__LINE__)
  1354   1354   static int unixLogErrorAtLine(
  1355   1355     int errcode,                    /* SQLite error code */
  1356   1356     const char *zFunc,              /* Name of OS function that failed */
  1357   1357     const char *zPath,              /* File path associated with error */
................................................................................
  1366   1366     */ 
  1367   1367   #if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)
  1368   1368     char aErr[80];
  1369   1369     memset(aErr, 0, sizeof(aErr));
  1370   1370     zErr = aErr;
  1371   1371   
  1372   1372     /* If STRERROR_R_CHAR_P (set by autoconf scripts) or __USE_GNU is defined,
  1373         -  ** assume that the system provides the the GNU version of strerror_r() that 
         1373  +  ** assume that the system provides the GNU version of strerror_r() that
  1374   1374     ** returns a pointer to a buffer containing the error message. That pointer 
  1375   1375     ** may point to aErr[], or it may point to some static storage somewhere. 
  1376   1376     ** Otherwise, assume that the system provides the POSIX version of 
  1377   1377     ** strerror_r(), which always writes an error message into aErr[].
  1378   1378     **
  1379   1379     ** If the code incorrectly assumes that it is the POSIX version that is
  1380   1380     ** available, the error message will often be an empty string. Not a

Changes to src/os_win.c.

  1460   1460   ** It logs a message using sqlite3_log() containing the current value of
  1461   1461   ** error code and, if possible, the human-readable equivalent from 
  1462   1462   ** FormatMessage.
  1463   1463   **
  1464   1464   ** The first argument passed to the macro should be the error code that
  1465   1465   ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). 
  1466   1466   ** The two subsequent arguments should be the name of the OS function that
  1467         -** failed and the the associated file-system path, if any.
         1467  +** failed and the associated file-system path, if any.
  1468   1468   */
  1469   1469   #define winLogError(a,b,c,d)   winLogErrorAtLine(a,b,c,d,__LINE__)
  1470   1470   static int winLogErrorAtLine(
  1471   1471     int errcode,                    /* SQLite error code */
  1472   1472     DWORD lastErrno,                /* Win32 last error */
  1473   1473     const char *zFunc,              /* Name of OS function that failed */
  1474   1474     const char *zPath,              /* File path associated with error */
................................................................................
  3594   3594          || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL 
  3595   3595          || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL 
  3596   3596          || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
  3597   3597     );
  3598   3598   
  3599   3599     assert( id!=0 );
  3600   3600     UNUSED_PARAMETER(pVfs);
         3601  +
         3602  +#if SQLITE_OS_WINRT
         3603  +  if( !sqlite3_temp_directory ){
         3604  +    sqlite3_log(SQLITE_ERROR,
         3605  +        "sqlite3_temp_directory variable should be set for WinRT");
         3606  +  }
         3607  +#endif
  3601   3608   
  3602   3609     pFile->h = INVALID_HANDLE_VALUE;
  3603   3610   
  3604   3611     /* If the second argument to this function is NULL, generate a 
  3605   3612     ** temporary file name to use 
  3606   3613     */
  3607   3614     if( !zUtf8Name ){
................................................................................
  3908   3915             && sAttrData.nFileSizeLow==0 ){
  3909   3916           attr = INVALID_FILE_ATTRIBUTES;
  3910   3917         }else{
  3911   3918           attr = sAttrData.dwFileAttributes;
  3912   3919         }
  3913   3920       }else{
  3914   3921         logIoerr(cnt);
  3915         -      if( lastErrno!=ERROR_FILE_NOT_FOUND ){
         3922  +      if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
  3916   3923           winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", zFilename);
  3917   3924           sqlite3_free(zConverted);
  3918   3925           return SQLITE_IOERR_ACCESS;
  3919   3926         }else{
  3920   3927           attr = INVALID_FILE_ATTRIBUTES;
  3921   3928         }
  3922   3929       }

Changes to src/pager.c.

    71     71   **     being deleted, truncated, or zeroed.
    72     72   ** 
    73     73   ** (6) If a master journal file is used, then all writes to the database file
    74     74   **     are synced prior to the master journal being deleted.
    75     75   ** 
    76     76   ** Definition: Two databases (or the same database at two points it time)
    77     77   ** are said to be "logically equivalent" if they give the same answer to
    78         -** all queries.  Note in particular the the content of freelist leaf
           78  +** all queries.  Note in particular the content of freelist leaf
    79     79   ** pages can be changed arbitarily without effecting the logical equivalence
    80     80   ** of the database.
    81     81   ** 
    82     82   ** (7) At any time, if any subset, including the empty set and the total set,
    83     83   **     of the unsynced changes to a rollback journal are removed and the 
    84     84   **     journal is rolled back, the resulting database file will be logical
    85     85   **     equivalent to the database file at the beginning of the transaction.
................................................................................
  3857   3857   /*
  3858   3858   ** Sync the journal. In other words, make sure all the pages that have
  3859   3859   ** been written to the journal have actually reached the surface of the
  3860   3860   ** disk and can be restored in the event of a hot-journal rollback.
  3861   3861   **
  3862   3862   ** If the Pager.noSync flag is set, then this function is a no-op.
  3863   3863   ** Otherwise, the actions required depend on the journal-mode and the 
  3864         -** device characteristics of the the file-system, as follows:
         3864  +** device characteristics of the file-system, as follows:
  3865   3865   **
  3866   3866   **   * If the journal file is an in-memory journal file, no action need
  3867   3867   **     be taken.
  3868   3868   **
  3869   3869   **   * Otherwise, if the device does not support the SAFE_APPEND property,
  3870   3870   **     then the nRec field of the most recently written journal header
  3871   3871   **     is updated to contain the number of journal records that have

Changes to src/rowset.c.

   436    436       return 1;
   437    437     }else{
   438    438       return 0;
   439    439     }
   440    440   }
   441    441   
   442    442   /*
   443         -** Check to see if element iRowid was inserted into the the rowset as
          443  +** Check to see if element iRowid was inserted into the rowset as
   444    444   ** part of any insert batch prior to iBatch.  Return 1 or 0.
   445    445   **
   446    446   ** If this is the first test of a new batch and if there exist entires
   447    447   ** on pRowSet->pEntry, then sort those entires into the forest at
   448    448   ** pRowSet->pForest so that they can be tested.
   449    449   */
   450    450   int sqlite3RowSetTest(RowSet *pRowSet, u8 iBatch, sqlite3_int64 iRowid){

Changes to src/select.c.

  1966   1966       sqlite3VdbeAddOp3(v, OP_Jump, j2+2, iContinue, j2+2);
  1967   1967       sqlite3VdbeJumpHere(v, j1);
  1968   1968       sqlite3ExprCodeCopy(pParse, pIn->iSdst, regPrev+1, pIn->nSdst);
  1969   1969       sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);
  1970   1970     }
  1971   1971     if( pParse->db->mallocFailed ) return 0;
  1972   1972   
  1973         -  /* Suppress the the first OFFSET entries if there is an OFFSET clause
         1973  +  /* Suppress the first OFFSET entries if there is an OFFSET clause
  1974   1974     */
  1975   1975     codeOffset(v, p, iContinue);
  1976   1976   
  1977   1977     switch( pDest->eDest ){
  1978   1978       /* Store the result as data using a unique key.
  1979   1979       */
  1980   1980       case SRT_Table:
................................................................................
  2684   2684   **
  2685   2685   **        The parent and sub-query may contain WHERE clauses. Subject to
  2686   2686   **        rules (11), (13) and (14), they may also contain ORDER BY,
  2687   2687   **        LIMIT and OFFSET clauses.  The subquery cannot use any compound
  2688   2688   **        operator other than UNION ALL because all the other compound
  2689   2689   **        operators have an implied DISTINCT which is disallowed by
  2690   2690   **        restriction (4).
         2691  +**
         2692  +**        Also, each component of the sub-query must return the same number
         2693  +**        of result columns. This is actually a requirement for any compound
         2694  +**        SELECT statement, but all the code here does is make sure that no
         2695  +**        such (illegal) sub-query is flattened. The caller will detect the
         2696  +**        syntax error and return a detailed message.
  2691   2697   **
  2692   2698   **  (18)  If the sub-query is a compound select, then all terms of the
  2693   2699   **        ORDER by clause of the parent must be simple references to 
  2694   2700   **        columns of the sub-query.
  2695   2701   **
  2696   2702   **  (19)  The subquery does not use LIMIT or the outer query does not
  2697   2703   **        have a WHERE clause.
................................................................................
  2828   2834       for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){
  2829   2835         testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );
  2830   2836         testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );
  2831   2837         assert( pSub->pSrc!=0 );
  2832   2838         if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0
  2833   2839          || (pSub1->pPrior && pSub1->op!=TK_ALL) 
  2834   2840          || pSub1->pSrc->nSrc<1
         2841  +       || pSub->pEList->nExpr!=pSub1->pEList->nExpr
  2835   2842         ){
  2836   2843           return 0;
  2837   2844         }
  2838   2845         testcase( pSub1->pSrc->nSrc>1 );
  2839   2846       }
  2840   2847   
  2841   2848       /* Restriction 18. */

Changes to src/shell.c.

    60     60   # define stifle_history(X)
    61     61   #endif
    62     62   
    63     63   #if defined(_WIN32) || defined(WIN32)
    64     64   # include <io.h>
    65     65   #define isatty(h) _isatty(h)
    66     66   #define access(f,m) _access((f),(m))
           67  +#undef popen
    67     68   #define popen(a,b) _popen((a),(b))
           69  +#undef pclose
    68     70   #define pclose(x) _pclose(x)
    69     71   #else
    70     72   /* Make sure isatty() has a prototype.
    71     73   */
    72     74   extern int isatty(int);
    73     75   #endif
    74     76   

Changes to src/sqlite.h.in.

   509    509   
   510    510   /* Reserved:                         0x00F00000 */
   511    511   
   512    512   /*
   513    513   ** CAPI3REF: Device Characteristics
   514    514   **
   515    515   ** The xDeviceCharacteristics method of the [sqlite3_io_methods]
   516         -** object returns an integer which is a vector of the these
          516  +** object returns an integer which is a vector of these
   517    517   ** bit values expressing I/O characteristics of the mass storage
   518    518   ** device that holds the file that the [sqlite3_io_methods]
   519    519   ** refers to.
   520    520   **
   521    521   ** The SQLITE_IOCAP_ATOMIC property means that all writes of
   522    522   ** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
   523    523   ** mean that writes of blocks that are nnn bytes in size and
................................................................................
  2663   2663   ** the results are undefined.
  2664   2664   **
  2665   2665   ** <b>Note to Windows users:</b>  The encoding used for the filename argument
  2666   2666   ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
  2667   2667   ** codepage is currently defined.  Filenames containing international
  2668   2668   ** characters must be converted to UTF-8 prior to passing them into
  2669   2669   ** sqlite3_open() or sqlite3_open_v2().
         2670  +**
         2671  +** <b>Note to Windows Runtime users:</b>  The temporary directory must be set
         2672  +** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various
         2673  +** features that require the use of temporary files may fail.
         2674  +**
         2675  +** See also: [sqlite3_temp_directory]
  2670   2676   */
  2671   2677   int sqlite3_open(
  2672   2678     const char *filename,   /* Database filename (UTF-8) */
  2673   2679     sqlite3 **ppDb          /* OUT: SQLite db handle */
  2674   2680   );
  2675   2681   int sqlite3_open16(
  2676   2682     const void *filename,   /* Database filename (UTF-16) */
................................................................................
  4467   4473   ** the [temp_store_directory pragma] always assumes that any string
  4468   4474   ** that this variable points to is held in memory obtained from 
  4469   4475   ** [sqlite3_malloc] and the pragma may attempt to free that memory
  4470   4476   ** using [sqlite3_free].
  4471   4477   ** Hence, if this variable is modified directly, either it should be
  4472   4478   ** made NULL or made to point to memory obtained from [sqlite3_malloc]
  4473   4479   ** or else the use of the [temp_store_directory pragma] should be avoided.
         4480  +**
         4481  +** <b>Note to Windows Runtime users:</b>  The temporary directory must be set
         4482  +** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various
         4483  +** features that require the use of temporary files may fail.  Here is an
         4484  +** example of how to do this using C++ with the Windows Runtime:
         4485  +**
         4486  +** <blockquote><pre>
         4487  +** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
         4488  +** &nbsp;     TemporaryFolder->Path->Data();
         4489  +** char zPathBuf&#91;MAX_PATH + 1&#93;;
         4490  +** memset(zPathBuf, 0, sizeof(zPathBuf));
         4491  +** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
         4492  +** &nbsp;     NULL, NULL);
         4493  +** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
         4494  +** </pre></blockquote>
  4474   4495   */
  4475   4496   SQLITE_EXTERN char *sqlite3_temp_directory;
  4476   4497   
  4477   4498   /*
  4478   4499   ** CAPI3REF: Name Of The Folder Holding Database Files
  4479   4500   **
  4480   4501   ** ^(If this global variable is made to point to a string which is

Changes to src/sqliteInt.h.

  1923   1923       sqlite3_index_info *pVtabIdx;  /* Virtual table index to use */
  1924   1924     } u;
  1925   1925   };
  1926   1926   
  1927   1927   /*
  1928   1928   ** For each nested loop in a WHERE clause implementation, the WhereInfo
  1929   1929   ** structure contains a single instance of this structure.  This structure
  1930         -** is intended to be private the the where.c module and should not be
         1930  +** is intended to be private to the where.c module and should not be
  1931   1931   ** access or modified by other modules.
  1932   1932   **
  1933   1933   ** The pIdxInfo field is used to help pick the best index on a
  1934   1934   ** virtual table.  The pIdxInfo pointer contains indexing
  1935   1935   ** information for the i-th table in the FROM clause before reordering.
  1936   1936   ** All the pIdxInfo pointers are freed by whereInfoFree() in where.c.
  1937   1937   ** All other information in the i-th WhereLevel object for the i-th table

Changes to src/test4.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** Code for testing the the SQLite library in a multithreaded environment.
           12  +** Code for testing the SQLite library in a multithreaded environment.
    13     13   */
    14     14   #include "sqliteInt.h"
    15     15   #include "tcl.h"
    16     16   #if SQLITE_OS_UNIX && SQLITE_THREADSAFE
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <pthread.h>

Changes to src/test_spellfix.c.

   218    218       if( (c==CCLASS_R || c==CCLASS_L) && cPrevX==CCLASS_VOWEL ){
   219    219          nOut--;   /* No vowels beside L or R */
   220    220       }
   221    221       cPrev = c;
   222    222       if( c==CCLASS_SILENT ) continue;
   223    223       cPrevX = c;
   224    224       c = className[c];
   225         -    if( c!=zOut[nOut-1] ) zOut[nOut++] = c;
          225  +    assert( nOut>=0 );
          226  +    if( nOut==0 || c!=zOut[nOut-1] ) zOut[nOut++] = c;
   226    227     }
   227    228     zOut[nOut] = 0;
   228    229     return zOut;
   229    230   }
   230    231   
   231    232   /*
   232    233   ** This is an SQL function wrapper around phoneticHash().  See

Changes to src/test_vfstrace.c.

    41     41   **
    42     42   ** The vfstrace_register() function creates a new "shim" VFS named by
    43     43   ** the zTraceName parameter.  A "shim" VFS is an SQLite backend that does
    44     44   ** not really perform the duties of a true backend, but simply filters or
    45     45   ** interprets VFS calls before passing them off to another VFS which does
    46     46   ** the actual work.  In this case the other VFS - the one that does the
    47     47   ** real work - is identified by the second parameter, zOldVfsName.  If
    48         -** the the 2nd parameter is NULL then the default VFS is used.  The common
           48  +** the 2nd parameter is NULL then the default VFS is used.  The common
    49     49   ** case is for the 2nd parameter to be NULL.
    50     50   **
    51     51   ** The third and fourth parameters are the pointer to the output function
    52     52   ** and the second argument to the output function.  For the SQLite
    53     53   ** command-line shell, when the -vfstrace option is used, these parameters
    54     54   ** are fputs and stderr, respectively.
    55     55   **

Changes to src/trigger.c.

   107    107       if( pName2->n>0 ){
   108    108         sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name");
   109    109         goto trigger_cleanup;
   110    110       }
   111    111       iDb = 1;
   112    112       pName = pName1;
   113    113     }else{
   114         -    /* Figure out the db that the the trigger will be created in */
          114  +    /* Figure out the db that the trigger will be created in */
   115    115       iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
   116    116       if( iDb<0 ){
   117    117         goto trigger_cleanup;
   118    118       }
   119    119     }
   120    120     if( !pTableName || db->mallocFailed ){
   121    121       goto trigger_cleanup;

Changes to src/vdbe.c.

   652    652           }
   653    653           nProgressOps = 0;
   654    654         }
   655    655         nProgressOps++;
   656    656       }
   657    657   #endif
   658    658   
   659         -    /* On any opcode with the "out2-prerelase" tag, free any
          659  +    /* On any opcode with the "out2-prerelease" tag, free any
   660    660       ** external allocations out of mem[p2] and set mem[p2] to be
   661    661       ** an undefined integer.  Opcodes will either fill in the integer
   662    662       ** value or convert mem[p2] to a different type.
   663    663       */
   664    664       assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] );
   665    665       if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){
   666    666         assert( pOp->p2>0 );

Changes to src/vdbeaux.c.

   770    770       pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n);
   771    771       pOp->p4type = P4_DYNAMIC;
   772    772     }
   773    773   }
   774    774   
   775    775   #ifndef NDEBUG
   776    776   /*
   777         -** Change the comment on the the most recently coded instruction.  Or
          777  +** Change the comment on the most recently coded instruction.  Or
   778    778   ** insert a No-op and add the comment to that new instruction.  This
   779    779   ** makes the code easier to read during debugging.  None of this happens
   780    780   ** in a production build.
   781    781   */
   782    782   static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
   783    783     assert( p->nOp>0 || p->aOp==0 );
   784    784     assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );

Changes to src/vtab.c.

   127    127   ** reaches zero, call the xDisconnect() method to delete the object.
   128    128   */
   129    129   void sqlite3VtabUnlock(VTable *pVTab){
   130    130     sqlite3 *db = pVTab->db;
   131    131   
   132    132     assert( db );
   133    133     assert( pVTab->nRef>0 );
   134         -  assert( sqlite3SafetyCheckOk(db) );
          134  +  assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );
   135    135   
   136    136     pVTab->nRef--;
   137    137     if( pVTab->nRef==0 ){
   138    138       sqlite3_vtab *p = pVTab->pVtab;
   139    139       if( p ){
   140    140         p->pModule->xDisconnect(p);
   141    141       }

Changes to src/wal.c.

   146    146   ** last frame in the wal before frame M for page P in the WAL, or return
   147    147   ** NULL if there are no frames for page P in the WAL prior to M.
   148    148   **
   149    149   ** The wal-index consists of a header region, followed by an one or
   150    150   ** more index blocks.  
   151    151   **
   152    152   ** The wal-index header contains the total number of frames within the WAL
   153         -** in the the mxFrame field.  
          153  +** in the mxFrame field.
   154    154   **
   155    155   ** Each index block except for the first contains information on 
   156    156   ** HASHTABLE_NPAGE frames. The first index block contains information on
   157    157   ** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and 
   158    158   ** HASHTABLE_NPAGE are selected so that together the wal-index header and
   159    159   ** first index block are the same size as all other index blocks in the
   160    160   ** wal-index.

Changes to src/where.c.

  5089   5089       if( (pLevel->plan.wsFlags & WHERE_TEMP_INDEX)!=0 ){
  5090   5090         constructAutomaticIndex(pParse, pWC, pTabItem, notReady, pLevel);
  5091   5091       }else
  5092   5092   #endif
  5093   5093       if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 ){
  5094   5094         Index *pIx = pLevel->plan.u.pIdx;
  5095   5095         KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIx);
  5096         -      int iIdxCur = pLevel->iIdxCur;
         5096  +      int iIndexCur = pLevel->iIdxCur;
  5097   5097         assert( pIx->pSchema==pTab->pSchema );
  5098         -      assert( iIdxCur>=0 );
  5099         -      sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIx->tnum, iDb,
         5098  +      assert( iIndexCur>=0 );
         5099  +      sqlite3VdbeAddOp4(v, OP_OpenRead, iIndexCur, pIx->tnum, iDb,
  5100   5100                           (char*)pKey, P4_KEYINFO_HANDOFF);
  5101   5101         VdbeComment((v, "%s", pIx->zName));
  5102   5102       }
  5103   5103       sqlite3CodeVerifySchema(pParse, iDb);
  5104   5104       notReady &= ~getMask(pWC->pMaskSet, pTabItem->iCursor);
  5105   5105     }
  5106   5106     pWInfo->iTop = sqlite3VdbeCurrentAddr(v);

Changes to test/crash.test.

   115    115   do_test crash-1.11 {
   116    116     catchsql {
   117    117       SELECT * FROM abc;
   118    118     }
   119    119   } {0 {}}
   120    120   
   121    121   #--------------------------------------------------------------------------
   122         -# The following tests test recovery when both the database file and the the
          122  +# The following tests test recovery when both the database file and the
   123    123   # journal file contain corrupt data. This can happen after pages are
   124    124   # written to the database file before a transaction is committed due to
   125    125   # cache-pressure.
   126    126   #
   127    127   # crash-2.1: Insert 18 pages of data into the database.
   128    128   # crash-2.2: Check the database file size looks ok.
   129    129   # crash-2.3: Delete 15 or so pages (with a 10 page page-cache), then crash.

Changes to test/journal1.test.

    37     37       INSERT INTO t1 SELECT a+2, a||b FROM t1;
    38     38       INSERT INTO t1 SELECT a+4, a||b FROM t1;
    39     39       SELECT count(*) FROM t1;
    40     40     }
    41     41   } 8
    42     42   
    43     43   # Make changes to the database and save the journal file.
    44         -# Then delete the database.  Replace the the journal file
           44  +# Then delete the database.  Replace the journal file
    45     45   # and try to create a new database with the same name.  The
    46     46   # old journal should not attempt to rollback into the new
    47     47   # database.
    48     48   #
    49     49   do_test journal1-1.2 {
    50     50     execsql {
    51     51       BEGIN;

Changes to test/permutations.test.

   138    138     test_set $allquicktests -exclude *malloc* *ioerr* *fault*
   139    139   ]
   140    140   
   141    141   test_suite "valgrind" -prefix "" -description {
   142    142     Run the "veryquick" test suite with a couple of multi-process tests (that
   143    143     fail under valgrind) omitted.
   144    144   } -files [
   145         -  test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test
          145  +  test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test atof1.test
   146    146   ] -initialize {
   147    147     set ::G(valgrind) 1
   148    148   } -shutdown {
   149    149     unset -nocomplain ::G(valgrind)
   150    150   }
   151    151   
   152    152   test_suite "quick" -prefix "" -description {

Changes to test/rowid.test.

   653    653   do_test rowid-11.4 {
   654    654     execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc'}
   655    655   } {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}
   656    656   
   657    657   # Test the automatic generation of rowids when the table already contains
   658    658   # a rowid with the maximum value.
   659    659   #
   660         -# Once the the maximum rowid is taken, rowids are normally chosen at
          660  +# Once the maximum rowid is taken, rowids are normally chosen at
   661    661   # random.  By by reseting the random number generator, we can cause
   662    662   # the rowid guessing loop to collide with prior rowids, and test the
   663    663   # loop out to its limit of 100 iterations.  After 100 collisions, the
   664    664   # rowid guesser gives up and reports SQLITE_FULL.
   665    665   #
   666    666   do_test rowid-12.1 {
   667    667     execsql {

Changes to test/select6.test.

    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Omit this whole file if the library is build without subquery support.
    21     21   ifcapable !subquery {
    22     22     finish_test
    23     23     return
    24     24   }
           25  +set ::testprefix select6
    25     26   
    26     27   do_test select6-1.0 {
    27     28     execsql {
    28     29       BEGIN;
    29     30       CREATE TABLE t1(x, y);
    30     31       INSERT INTO t1 VALUES(1,1);
    31     32       INSERT INTO t1 VALUES(2,2);
................................................................................
   508    509   } {2 12 3 13 4 14}
   509    510   do_test select6-9.11 {
   510    511     execsql {
   511    512       SELECT x, y FROM (SELECT x, (SELECT 10)+x y FROM t1 LIMIT -1 OFFSET 1);
   512    513     }
   513    514   } {2 12 3 13 4 14}
   514    515   
          516  +
          517  +#-------------------------------------------------------------------------
          518  +# Test that if a UNION ALL sub-query that would otherwise be eligible for
          519  +# flattening consists of two or more SELECT statements that do not all 
          520  +# return the same number of result columns, the error is detected.
          521  +#
          522  +do_execsql_test 10.1 {
          523  +  CREATE TABLE t(i,j,k);
          524  +  CREATE TABLE j(l,m);
          525  +  CREATE TABLE k(o);
          526  +}
          527  +
          528  +set err [list 1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}]
          529  +
          530  +do_execsql_test 10.2 {
          531  +  SELECT * FROM (SELECT * FROM t), j;
          532  +}
          533  +do_catchsql_test 10.3 {
          534  +  SELECT * FROM t UNION ALL SELECT * FROM j
          535  +} $err
          536  +do_catchsql_test 10.4 {
          537  +  SELECT * FROM (SELECT i FROM t UNION ALL SELECT l, m FROM j)
          538  +} $err
          539  +do_catchsql_test 10.5 {
          540  +  SELECT * FROM (SELECT j FROM t UNION ALL SELECT * FROM j)
          541  +} $err
          542  +do_catchsql_test 10.6 {
          543  +  SELECT * FROM (SELECT * FROM t UNION ALL SELECT * FROM j)
          544  +} $err
          545  +do_catchsql_test 10.7 {
          546  +  SELECT * FROM (
          547  +    SELECT * FROM t UNION ALL 
          548  +    SELECT l,m,l FROM j UNION ALL
          549  +    SELECT * FROM k
          550  +  )
          551  +} $err
          552  +do_catchsql_test 10.8 {
          553  +  SELECT * FROM (
          554  +    SELECT * FROM k UNION ALL
          555  +    SELECT * FROM t UNION ALL 
          556  +    SELECT l,m,l FROM j 
          557  +  )
          558  +} $err
   515    559   
   516    560   
   517    561   finish_test

Changes to test/wal2.test.

    90     90   # and a reader ([db2]). For each of the 8 integer fields in the wal-index
    91     91   # header (6 fields and 2 checksum values), do the following:
    92     92   #
    93     93   #   1. Modify the database using the writer.
    94     94   #
    95     95   #   2. Attempt to read the database using the reader. Before the reader
    96     96   #      has a chance to snapshot the wal-index header, increment one
    97         -#      of the the integer fields (so that the reader ends up with a corrupted
           97  +#      of the integer fields (so that the reader ends up with a corrupted
    98     98   #      header).
    99     99   #
   100    100   #   3. Check that the reader recovers the wal-index and reads the correct
   101    101   #      database content.
   102    102   #
   103    103   do_test wal2-1.0 {
   104    104     proc tvfs_cb {method filename args} {