/ Check-in [e5ca79d2]
Login

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

Overview
Comment:Merge latest trunk changes with this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ota-update
Files: files | file ages | folders
SHA1:e5ca79d2d3c066252b0baa4f76ddbe0ee3b14cb6
User & Date: dan 2015-02-23 16:17:46
Context
2015-02-23
20:09
Fix building with ENABLE_OTA and OMIT_LOAD_EXTENSION. check-in: d6d21ff5 user: dan tags: ota-update
16:17
Merge latest trunk changes with this branch. check-in: e5ca79d2 user: dan tags: ota-update
15:41
Change SQLITE_FCNTL_ZIPVFS_PAGER to SQLITE_FCNTL_ZIPVFS. check-in: f7865b94 user: dan tags: ota-update
2015-02-21
15:42
Update document on sqlite3_mprintf() and related functions. Discuss the %w format and point out that obscure ANSI-C formats are not supported. No changes to code. check-in: f8917ba4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

   187    187           zKey = (char *)sqlite3_value_blob(argv[2]);
   188    188           rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
   189    189           break;
   190    190   
   191    191         case SQLITE_NULL:
   192    192           /* No key specified.  Use the key from the main database */
   193    193           sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
   194         -        if( nKey>0 || sqlite3BtreeGetReserve(db->aDb[0].pBt)>0 ){
          194  +        if( nKey>0 || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
   195    195             rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
   196    196           }
   197    197           break;
   198    198       }
   199    199     }
   200    200   #endif
   201    201   

Changes to src/backup.c.

   243    243     const int nCopy = MIN(nSrcPgsz, nDestPgsz);
   244    244     const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz;
   245    245   #ifdef SQLITE_HAS_CODEC
   246    246     /* Use BtreeGetReserveNoMutex() for the source b-tree, as although it is
   247    247     ** guaranteed that the shared-mutex is held by this thread, handle
   248    248     ** p->pSrc may not actually be the owner.  */
   249    249     int nSrcReserve = sqlite3BtreeGetReserveNoMutex(p->pSrc);
   250         -  int nDestReserve = sqlite3BtreeGetReserve(p->pDest);
          250  +  int nDestReserve = sqlite3BtreeGetOptimalReserve(p->pDest);
   251    251   #endif
   252    252     int rc = SQLITE_OK;
   253    253     i64 iOff;
   254    254   
   255    255     assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 );
   256    256     assert( p->bDestLocked );
   257    257     assert( !isFatalError(p->rc) );

Changes to src/btree.c.

  2401   2401   ** and autovacuum mode can no longer be changed.
  2402   2402   */
  2403   2403   int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){
  2404   2404     int rc = SQLITE_OK;
  2405   2405     BtShared *pBt = p->pBt;
  2406   2406     assert( nReserve>=-1 && nReserve<=255 );
  2407   2407     sqlite3BtreeEnter(p);
         2408  +#if SQLITE_HAS_CODEC
         2409  +  if( nReserve>pBt->optimalReserve ) pBt->optimalReserve = (u8)nReserve;
         2410  +#endif
  2408   2411     if( pBt->btsFlags & BTS_PAGESIZE_FIXED ){
  2409   2412       sqlite3BtreeLeave(p);
  2410   2413       return SQLITE_READONLY;
  2411   2414     }
  2412   2415     if( nReserve<0 ){
  2413   2416       nReserve = pBt->pageSize - pBt->usableSize;
  2414   2417     }
................................................................................
  2430   2433   /*
  2431   2434   ** Return the currently defined page size
  2432   2435   */
  2433   2436   int sqlite3BtreeGetPageSize(Btree *p){
  2434   2437     return p->pBt->pageSize;
  2435   2438   }
  2436   2439   
  2437         -#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)
  2438   2440   /*
  2439   2441   ** This function is similar to sqlite3BtreeGetReserve(), except that it
  2440   2442   ** may only be called if it is guaranteed that the b-tree mutex is already
  2441   2443   ** held.
  2442   2444   **
  2443   2445   ** This is useful in one special case in the backup API code where it is
  2444   2446   ** known that the shared b-tree mutex is held, but the mutex on the 
  2445   2447   ** database handle that owns *p is not. In this case if sqlite3BtreeEnter()
  2446   2448   ** were to be called, it might collide with some other operation on the
  2447   2449   ** database handle that owns *p, causing undefined behavior.
  2448   2450   */
  2449   2451   int sqlite3BtreeGetReserveNoMutex(Btree *p){
         2452  +  int n;
  2450   2453     assert( sqlite3_mutex_held(p->pBt->mutex) );
  2451         -  return p->pBt->pageSize - p->pBt->usableSize;
         2454  +  n = p->pBt->pageSize - p->pBt->usableSize;
         2455  +  return n;
  2452   2456   }
  2453         -#endif /* SQLITE_HAS_CODEC || SQLITE_DEBUG */
  2454   2457   
  2455         -#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM)
  2456   2458   /*
  2457   2459   ** Return the number of bytes of space at the end of every page that
  2458   2460   ** are intentually left unused.  This is the "reserved" space that is
  2459   2461   ** sometimes used by extensions.
         2462  +**
         2463  +** If SQLITE_HAS_MUTEX is defined then the number returned is the
         2464  +** greater of the current reserved space and the maximum requested
         2465  +** reserve space.
  2460   2466   */
  2461         -int sqlite3BtreeGetReserve(Btree *p){
         2467  +int sqlite3BtreeGetOptimalReserve(Btree *p){
  2462   2468     int n;
  2463   2469     sqlite3BtreeEnter(p);
  2464         -  n = p->pBt->pageSize - p->pBt->usableSize;
         2470  +  n = sqlite3BtreeGetReserveNoMutex(p);
         2471  +#ifdef SQLITE_HAS_CODEC
         2472  +  if( n<p->pBt->optimalReserve ) n = p->pBt->optimalReserve;
         2473  +#endif
  2465   2474     sqlite3BtreeLeave(p);
  2466   2475     return n;
  2467   2476   }
         2477  +
  2468   2478   
  2469   2479   /*
  2470   2480   ** Set the maximum page count for a database if mxPage is positive.
  2471   2481   ** No changes are made if mxPage is 0 or negative.
  2472   2482   ** Regardless of the value of mxPage, return the maximum page count.
  2473   2483   */
  2474   2484   int sqlite3BtreeMaxPageCount(Btree *p, int mxPage){
................................................................................
  2492   2502       p->pBt->btsFlags &= ~BTS_SECURE_DELETE;
  2493   2503       if( newFlag ) p->pBt->btsFlags |= BTS_SECURE_DELETE;
  2494   2504     } 
  2495   2505     b = (p->pBt->btsFlags & BTS_SECURE_DELETE)!=0;
  2496   2506     sqlite3BtreeLeave(p);
  2497   2507     return b;
  2498   2508   }
  2499         -#endif /* !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM) */
  2500   2509   
  2501   2510   /*
  2502   2511   ** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'
  2503   2512   ** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it
  2504   2513   ** is disabled. The default value for the auto-vacuum property is 
  2505   2514   ** determined by the SQLITE_DEFAULT_AUTOVACUUM macro.
  2506   2515   */

Changes to src/btree.h.

    69     69   int sqlite3BtreeSetPagerFlags(Btree*,unsigned);
    70     70   int sqlite3BtreeSyncDisabled(Btree*);
    71     71   int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
    72     72   int sqlite3BtreeGetPageSize(Btree*);
    73     73   int sqlite3BtreeMaxPageCount(Btree*,int);
    74     74   u32 sqlite3BtreeLastPage(Btree*);
    75     75   int sqlite3BtreeSecureDelete(Btree*,int);
    76         -int sqlite3BtreeGetReserve(Btree*);
    77         -#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)
           76  +int sqlite3BtreeGetOptimalReserve(Btree*);
    78     77   int sqlite3BtreeGetReserveNoMutex(Btree *p);
    79         -#endif
    80     78   int sqlite3BtreeSetAutoVacuum(Btree *, int);
    81     79   int sqlite3BtreeGetAutoVacuum(Btree *);
    82     80   int sqlite3BtreeBeginTrans(Btree*,int);
    83     81   int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
    84     82   int sqlite3BtreeCommitPhaseTwo(Btree*, int);
    85     83   int sqlite3BtreeCommit(Btree*);
    86     84   int sqlite3BtreeRollback(Btree*,int,int);

Changes to src/btreeInt.h.

   414    414   #ifndef SQLITE_OMIT_AUTOVACUUM
   415    415     u8 autoVacuum;        /* True if auto-vacuum is enabled */
   416    416     u8 incrVacuum;        /* True if incr-vacuum is enabled */
   417    417     u8 bDoTruncate;       /* True to truncate db on commit */
   418    418   #endif
   419    419     u8 inTransaction;     /* Transaction state */
   420    420     u8 max1bytePayload;   /* Maximum first byte of cell for a 1-byte payload */
          421  +#ifdef SQLITE_HAS_CODEC
          422  +  u8 optimalReserve;    /* Desired amount of reserved space per page */
          423  +#endif
   421    424     u16 btsFlags;         /* Boolean parameters.  See BTS_* macros below */
   422    425     u16 maxLocal;         /* Maximum local payload in non-LEAFDATA tables */
   423    426     u16 minLocal;         /* Minimum local payload in non-LEAFDATA tables */
   424    427     u16 maxLeaf;          /* Maximum local payload in a LEAFDATA table */
   425    428     u16 minLeaf;          /* Minimum local payload in a LEAFDATA table */
   426    429     u32 pageSize;         /* Total number of bytes on a page */
   427    430     u32 usableSize;       /* Number of usable bytes on each page */

Changes to src/global.c.

    42     42   #ifdef SQLITE_EBCDIC
    43     43         0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, /* 0x */
    44     44        16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */
    45     45        32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */
    46     46        48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */
    47     47        64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */
    48     48        80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */
    49         -     96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */
    50         -    112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */
           49  +     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */
           50  +    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */
    51     51       128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */
    52         -    144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */
           52  +    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */
    53     53       160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */
    54     54       176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */
    55     55       192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */
    56     56       208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */
    57         -    224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */
    58         -    239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */
           57  +    224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */
           58  +    240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */
    59     59   #endif
    60     60   };
    61     61   
    62     62   /*
    63     63   ** The following 256 byte lookup table is used to support SQLites built-in
    64     64   ** equivalents to the following standard library functions:
    65     65   **

Changes to src/os_unix.c.

   250    250   #else
   251    251   # define UNIXFILE_DIRSYNC    0x00
   252    252   #endif
   253    253   #define UNIXFILE_PSOW        0x10     /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */
   254    254   #define UNIXFILE_DELETE      0x20     /* Delete on close */
   255    255   #define UNIXFILE_URI         0x40     /* Filename might have query parameters */
   256    256   #define UNIXFILE_NOLOCK      0x80     /* Do no file locking */
   257         -#define UNIXFILE_WARNED    0x0100     /* verifyDbFile() warnings have been issued */
          257  +#define UNIXFILE_WARNED    0x0100     /* verifyDbFile() warnings issued */
   258    258   
   259    259   /*
   260    260   ** Include code that is common to all os_*.c files
   261    261   */
   262    262   #include "os_common.h"
   263    263   
   264    264   /*
................................................................................
   713    713   #undef osFcntl
   714    714   #define osFcntl lockTrace
   715    715   #endif /* SQLITE_LOCK_TRACE */
   716    716   
   717    717   /*
   718    718   ** Retry ftruncate() calls that fail due to EINTR
   719    719   **
   720         -** All calls to ftruncate() within this file should be made through this wrapper.
   721         -** On the Android platform, bypassing the logic below could lead to a corrupt
   722         -** database.
          720  +** All calls to ftruncate() within this file should be made through
          721  +** this wrapper.  On the Android platform, bypassing the logic below
          722  +** could lead to a corrupt database.
   723    723   */
   724    724   static int robust_ftruncate(int h, sqlite3_int64 sz){
   725    725     int rc;
   726    726   #ifdef __ANDROID__
   727    727     /* On Android, ftruncate() always uses 32-bit offsets, even if 
   728    728     ** _FILE_OFFSET_BITS=64 is defined. This means it is unsafe to attempt to
   729    729     ** truncate a file to any size larger than 2GiB. Silently ignore any
................................................................................
  1175   1175     if( osClose(h) ){
  1176   1176       unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
  1177   1177                          pFile ? pFile->zPath : 0, lineno);
  1178   1178     }
  1179   1179   }
  1180   1180   
  1181   1181   /*
  1182         -** Set the pFile->lastErrno.  Do this in a subroutine as that provides a convenient
  1183         -** place to set a breakpoint.
         1182  +** Set the pFile->lastErrno.  Do this in a subroutine as that provides
         1183  +** a convenient place to set a breakpoint.
  1184   1184   */
  1185   1185   static void storeLastErrno(unixFile *pFile, int error){
  1186   1186     pFile->lastErrno = error;
  1187   1187   }
  1188   1188   
  1189   1189   /*
  1190   1190   ** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.
................................................................................
  1779   1779       ** write lock until the rest is covered by a read lock:
  1780   1780       **  1:   [WWWWW]
  1781   1781       **  2:   [....W]
  1782   1782       **  3:   [RRRRW]
  1783   1783       **  4:   [RRRR.]
  1784   1784       */
  1785   1785       if( eFileLock==SHARED_LOCK ){
  1786         -      int tErrno;               /* Error code from system call errors */
  1787         -
  1788   1786   #if !defined(__APPLE__) || !SQLITE_ENABLE_LOCKING_STYLE
  1789   1787         (void)handleNFSUnlock;
  1790   1788         assert( handleNFSUnlock==0 );
  1791   1789   #endif
  1792   1790   #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
  1793   1791         if( handleNFSUnlock ){
         1792  +        int tErrno;               /* Error code from system call errors */
  1794   1793           off_t divSize = SHARED_SIZE - 1;
  1795   1794           
  1796   1795           lock.l_type = F_UNLCK;
  1797   1796           lock.l_whence = SEEK_SET;
  1798   1797           lock.l_start = SHARED_FIRST;
  1799   1798           lock.l_len = divSize;
  1800   1799           if( unixFileLock(pFile, &lock)==(-1) ){
................................................................................
  3257   3256   
  3258   3257     assert( nBuf==(nBuf&0x1ffff) );
  3259   3258     assert( fd>2 );
  3260   3259     nBuf &= 0x1ffff;
  3261   3260     TIMER_START;
  3262   3261   
  3263   3262   #if defined(USE_PREAD)
  3264         -  do{ rc = osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );
         3263  +  do{ rc = (int)osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );
  3265   3264   #elif defined(USE_PREAD64)
  3266         -  do{ rc = osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
         3265  +  do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
  3267   3266   #else
  3268   3267     do{
  3269   3268       i64 iSeek = lseek(fd, iOff, SEEK_SET);
  3270   3269       SimulateIOError( iSeek-- );
  3271   3270   
  3272   3271       if( iSeek!=iOff ){
  3273   3272         if( piErrno ) *piErrno = (iSeek==-1 ? errno : 0);
................................................................................
  4966   4965   **
  4967   4966   **   *  A constant sqlite3_io_methods object call METHOD that has locking
  4968   4967   **      methods CLOSE, LOCK, UNLOCK, CKRESLOCK.
  4969   4968   **
  4970   4969   **   *  An I/O method finder function called FINDER that returns a pointer
  4971   4970   **      to the METHOD object in the previous bullet.
  4972   4971   */
  4973         -#define IOMETHODS(FINDER, METHOD, VERSION, CLOSE, LOCK, UNLOCK, CKLOCK, SHMMAP) \
         4972  +#define IOMETHODS(FINDER,METHOD,VERSION,CLOSE,LOCK,UNLOCK,CKLOCK,SHMMAP)     \
  4974   4973   static const sqlite3_io_methods METHOD = {                                   \
  4975   4974      VERSION,                    /* iVersion */                                \
  4976   4975      CLOSE,                      /* xClose */                                  \
  4977   4976      unixRead,                   /* xRead */                                   \
  4978   4977      unixWrite,                  /* xWrite */                                  \
  4979   4978      unixTruncate,               /* xTruncate */                               \
  4980   4979      unixSync,                   /* xSync */                                   \
................................................................................
  5874   5873       int useProxy = 0;
  5875   5874   
  5876   5875       /* SQLITE_FORCE_PROXY_LOCKING==1 means force always use proxy, 0 means 
  5877   5876       ** never use proxy, NULL means use proxy for non-local files only.  */
  5878   5877       if( envforce!=NULL ){
  5879   5878         useProxy = atoi(envforce)>0;
  5880   5879       }else{
  5881         -      if( statfs(zPath, &fsInfo) == -1 ){
  5882         -        /* In theory, the close(fd) call is sub-optimal. If the file opened
  5883         -        ** with fd is a database file, and there are other connections open
  5884         -        ** on that file that are currently holding advisory locks on it,
  5885         -        ** then the call to close() will cancel those locks. In practice,
  5886         -        ** we're assuming that statfs() doesn't fail very often. At least
  5887         -        ** not while other file descriptors opened by the same process on
  5888         -        ** the same file are working.  */
  5889         -        storeLastErrno(p, errno);
  5890         -        robust_close(p, fd, __LINE__);
  5891         -        rc = SQLITE_IOERR_ACCESS;
  5892         -        goto open_finished;
  5893         -      }
  5894   5880         useProxy = !(fsInfo.f_flags&MNT_LOCAL);
  5895   5881       }
  5896   5882       if( useProxy ){
  5897   5883         rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
  5898   5884         if( rc==SQLITE_OK ){
  5899   5885           rc = proxyTransformUnixFile((unixFile*)pFile, ":auto:");
  5900   5886           if( rc!=SQLITE_OK ){
................................................................................
  6776   6762           continue; 
  6777   6763         }
  6778   6764         
  6779   6765         assert( nTries==3 );
  6780   6766         if( 0==proxyBreakConchLock(pFile, myHostID) ){
  6781   6767           rc = SQLITE_OK;
  6782   6768           if( lockType==EXCLUSIVE_LOCK ){
  6783         -          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);          
         6769  +          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);
  6784   6770           }
  6785   6771           if( !rc ){
  6786   6772             rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);
  6787   6773           }
  6788   6774         }
  6789   6775       }
  6790   6776     } while( rc==SQLITE_BUSY && nTries<3 );

Changes to src/sqlite.h.in.

  2234   2234   void sqlite3_free_table(char **result);
  2235   2235   
  2236   2236   /*
  2237   2237   ** CAPI3REF: Formatted String Printing Functions
  2238   2238   **
  2239   2239   ** These routines are work-alikes of the "printf()" family of functions
  2240   2240   ** from the standard C library.
         2241  +** These routines understand most of the common K&R formatting options,
         2242  +** plus some additional non-standard formats, detailed below.
         2243  +** Note that some of the more obscure formatting options from recent
         2244  +** C-library standards are omitted from this implementation.
  2241   2245   **
  2242   2246   ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
  2243   2247   ** results into memory obtained from [sqlite3_malloc()].
  2244   2248   ** The strings returned by these two routines should be
  2245   2249   ** released by [sqlite3_free()].  ^Both routines return a
  2246   2250   ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
  2247   2251   ** memory to hold the resulting string.
................................................................................
  2266   2270   ** written will be n-1 characters.
  2267   2271   **
  2268   2272   ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().
  2269   2273   **
  2270   2274   ** These routines all implement some additional formatting
  2271   2275   ** options that are useful for constructing SQL statements.
  2272   2276   ** All of the usual printf() formatting options apply.  In addition, there
  2273         -** is are "%q", "%Q", and "%z" options.
         2277  +** is are "%q", "%Q", "%w" and "%z" options.
  2274   2278   **
  2275   2279   ** ^(The %q option works like %s in that it substitutes a nul-terminated
  2276   2280   ** string from the argument list.  But %q also doubles every '\'' character.
  2277   2281   ** %q is designed for use inside a string literal.)^  By doubling each '\''
  2278   2282   ** character it escapes that character and allows it to be inserted into
  2279   2283   ** the string.
  2280   2284   **
................................................................................
  2318   2322   **  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
  2319   2323   **  sqlite3_exec(db, zSQL, 0, 0, 0);
  2320   2324   **  sqlite3_free(zSQL);
  2321   2325   ** </pre></blockquote>
  2322   2326   **
  2323   2327   ** The code above will render a correct SQL statement in the zSQL
  2324   2328   ** variable even if the zText variable is a NULL pointer.
         2329  +**
         2330  +** ^(The "%w" formatting option is like "%q" except that it expects to
         2331  +** be contained within double-quotes instead of single quotes, and it
         2332  +** escapes the double-quote character instead of the single-quote
         2333  +** character.)^  The "%w" formatting option is intended for safely inserting
         2334  +** table and column names into a constructed SQL statement.
  2325   2335   **
  2326   2336   ** ^(The "%z" formatting option works like "%s" but with the
  2327   2337   ** addition that after the string has been read and copied into
  2328   2338   ** the result, [sqlite3_free()] is called on the input string.)^
  2329   2339   */
  2330   2340   char *sqlite3_mprintf(const char*,...);
  2331   2341   char *sqlite3_vmprintf(const char*, va_list);

Changes to src/tclsqlite.c.

  3752   3752       extern int Sqlitetestintarray_Init(Tcl_Interp*);
  3753   3753       extern int Sqlitetestvfs_Init(Tcl_Interp *);
  3754   3754       extern int Sqlitetestrtree_Init(Tcl_Interp*);
  3755   3755       extern int Sqlitequota_Init(Tcl_Interp*);
  3756   3756       extern int Sqlitemultiplex_Init(Tcl_Interp*);
  3757   3757       extern int SqliteSuperlock_Init(Tcl_Interp*);
  3758   3758       extern int SqlitetestSyscall_Init(Tcl_Interp*);
  3759         -#if SQLITE_ENABLE_OTA
  3760   3759       extern int SqliteOta_Init(Tcl_Interp*);
  3761         -#endif
  3762   3760   
  3763   3761   #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)
  3764   3762       extern int Sqlitetestfts3_Init(Tcl_Interp *interp);
  3765   3763   #endif
  3766   3764   
  3767   3765   #ifdef SQLITE_ENABLE_ZIPVFS
  3768   3766       extern int Zipvfs_Init(Tcl_Interp*);
................................................................................
  3798   3796       Sqlitetestintarray_Init(interp);
  3799   3797       Sqlitetestvfs_Init(interp);
  3800   3798       Sqlitetestrtree_Init(interp);
  3801   3799       Sqlitequota_Init(interp);
  3802   3800       Sqlitemultiplex_Init(interp);
  3803   3801       SqliteSuperlock_Init(interp);
  3804   3802       SqlitetestSyscall_Init(interp);
  3805         -#if SQLITE_ENABLE_OTA
  3806   3803       SqliteOta_Init(interp);
  3807         -#endif
  3808   3804   
  3809   3805   #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)
  3810   3806       Sqlitetestfts3_Init(interp);
  3811   3807   #endif
  3812   3808   
  3813   3809       Tcl_CreateObjCommand(
  3814   3810           interp, "load_testfixture_extensions", init_all_cmd, 0, 0

Changes to src/test_stat.c.

   297    297     }
   298    298     p->nUnused = nUnused;
   299    299     p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);
   300    300     szPage = sqlite3BtreeGetPageSize(pBt);
   301    301   
   302    302     if( p->nCell ){
   303    303       int i;                        /* Used to iterate through cells */
   304         -    int nUsable = szPage - sqlite3BtreeGetReserve(pBt);
          304  +    int nUsable;                  /* Usable bytes per page */
   305    305   
          306  +    sqlite3BtreeEnter(pBt);
          307  +    nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt);
          308  +    sqlite3BtreeLeave(pBt);
   306    309       p->aCell = sqlite3_malloc((p->nCell+1) * sizeof(StatCell));
   307    310       memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell));
   308    311   
   309    312       for(i=0; i<p->nCell; i++){
   310    313         StatCell *pCell = &p->aCell[i];
   311    314   
   312    315         iOff = get2byte(&aData[nHdr+i*2]);
................................................................................
   421    424   
   422    425       /* Page p itself has already been visited. */
   423    426       StatPage *p = &pCsr->aPage[pCsr->iPage];
   424    427   
   425    428       while( p->iCell<p->nCell ){
   426    429         StatCell *pCell = &p->aCell[p->iCell];
   427    430         if( pCell->iOvfl<pCell->nOvfl ){
   428         -        int nUsable = sqlite3BtreeGetPageSize(pBt)-sqlite3BtreeGetReserve(pBt);
          431  +        int nUsable;
          432  +        sqlite3BtreeEnter(pBt);
          433  +        nUsable = sqlite3BtreeGetPageSize(pBt) - 
          434  +                        sqlite3BtreeGetReserveNoMutex(pBt);
          435  +        sqlite3BtreeLeave(pBt);
   429    436           pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
   430    437           pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];
   431    438           pCsr->zPagetype = "overflow";
   432    439           pCsr->nCell = 0;
   433    440           pCsr->nMxPayload = 0;
   434    441           pCsr->zPath = sqlite3_mprintf(
   435    442               "%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl

Changes to src/vacuum.c.

   180    180   
   181    181     /* The call to execSql() to attach the temp database has left the file
   182    182     ** locked (as there was more than one active statement when the transaction
   183    183     ** to read the schema was concluded. Unlock it here so that this doesn't
   184    184     ** cause problems for the call to BtreeSetPageSize() below.  */
   185    185     sqlite3BtreeCommit(pTemp);
   186    186   
   187         -  nRes = sqlite3BtreeGetReserve(pMain);
          187  +  nRes = sqlite3BtreeGetOptimalReserve(pMain);
   188    188   
   189    189     /* A VACUUM cannot change the pagesize of an encrypted database. */
   190    190   #ifdef SQLITE_HAS_CODEC
   191    191     if( db->nextPagesize ){
   192    192       extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
   193    193       int nKey;
   194    194       char *zKey;

Changes to test/permutations.test.

   109    109     speed1.test speed1p.test speed2.test speed3.test speed4.test 
   110    110     speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
   111    111     thread003.test thread004.test thread005.test trans2.test vacuum3.test 
   112    112     incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
   113    113     vtab_err.test walslow.test walcrash.test walcrash3.test
   114    114     walthread.test rtree3.test indexfault.test securedel2.test
   115    115     sort3.test sort4.test fts4growth.test fts4growth2.test
   116         -  bigsort.test
          116  +  bigsort.test ota.test
   117    117   }]
   118    118   if {[info exists ::env(QUICKTEST_INCLUDE)]} {
   119    119     set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
   120    120   }
   121    121   if {[info exists ::env(QUICKTEST_OMIT)]} {
   122    122     foreach x [split $::env(QUICKTEST_OMIT) ,] {
   123    123       regsub -all \\y$x\\y $allquicktests {} allquicktests