/ Check-in [c5709036]
Login

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

Overview
Comment:Merge the latest trunk changes into the sessions branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: c5709036087b6b4fb6391ab7e4b4b870aac87a31
User & Date: drh 2011-08-03 21:46:58
Context
2011-08-26
19:20
Merge the latest trunk changes into the sessions branch. check-in: eb036d6f user: drh tags: sessions
2011-08-03
21:46
Merge the latest trunk changes into the sessions branch. check-in: c5709036 user: drh tags: sessions
21:32
Avoid segfaulting on an incremental blob write if SQLITE_ENABLE_PREUPDATE_HOOK set but no pre-update hooks are defined. check-in: 62c44634 user: drh tags: sessions
16:40
Update the OP_Move opcode to shift the pScopyFrom pointer of aliases when compiled with SQLITE_DEBUG. Ticket [d63523637517386191]. check-in: a2135ad1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to doc/lemon.html.

   278    278   tokens) and it honors the same commenting conventions as C and C++.</p>
   279    279   
   280    280   <h3>Terminals and Nonterminals</h3>
   281    281   
   282    282   <p>A terminal symbol (token) is any string of alphanumeric
   283    283   and underscore characters
   284    284   that begins with an upper case letter.
   285         -A terminal can contain lower class letters after the first character,
          285  +A terminal can contain lowercase letters after the first character,
   286    286   but the usual convention is to make terminals all upper case.
   287    287   A nonterminal, on the other hand, is any string of alphanumeric
   288    288   and underscore characters than begins with a lower case letter.
   289    289   Again, the usual convention is to make nonterminals use all lower
   290    290   case letters.</p>
   291    291   
   292    292   <p>In Lemon, terminal and nonterminal symbols do not need to 

Changes to src/os_common.h.

    26     26   ** switch.  The following code should catch this problem at compile-time.
    27     27   */
    28     28   #ifdef MEMORY_DEBUG
    29     29   # error "The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead."
    30     30   #endif
    31     31   
    32     32   #ifdef SQLITE_DEBUG
    33         -int sqlite3OSTrace = 0;
    34         -#define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
           33  +# ifndef SQLITE_DEBUG_OS_TRACE
           34  +#   define SQLITE_DEBUG_OS_TRACE 0
           35  +# endif
           36  +  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
           37  +# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
    35     38   #else
    36         -#define OSTRACE(X)
           39  +# define OSTRACE(X)
    37     40   #endif
    38     41   
    39     42   /*
    40     43   ** Macros for performance tracing.  Normally turned off.  Only works
    41     44   ** on i486 hardware.
    42     45   */
    43     46   #ifdef SQLITE_PERFORMANCE_TRACE

Changes to src/os_unix.c.

   246    246     char aPadding[32];
   247    247   #endif
   248    248   };
   249    249   
   250    250   /*
   251    251   ** Allowed values for the unixFile.ctrlFlags bitmask:
   252    252   */
   253         -#define UNIXFILE_EXCL   0x01     /* Connections from one process only */
   254         -#define UNIXFILE_RDONLY 0x02     /* Connection is read only */
          253  +#define UNIXFILE_EXCL        0x01     /* Connections from one process only */
          254  +#define UNIXFILE_RDONLY      0x02     /* Connection is read only */
          255  +#define UNIXFILE_PERSIST_WAL 0x04     /* Persistent WAL mode */
   255    256   
   256    257   /*
   257    258   ** Include code that is common to all os_*.c files
   258    259   */
   259    260   #include "os_common.h"
   260    261   
   261    262   /*
................................................................................
  3391   3392   ** file-control operation.
  3392   3393   **
  3393   3394   ** If the user has configured a chunk-size for this file, it could be
  3394   3395   ** that the file needs to be extended at this point. Otherwise, the
  3395   3396   ** SQLITE_FCNTL_SIZE_HINT operation is a no-op for Unix.
  3396   3397   */
  3397   3398   static int fcntlSizeHint(unixFile *pFile, i64 nByte){
  3398         -  if( pFile->szChunk ){
         3399  +  { /* preserve indentation of removed "if" */
  3399   3400       i64 nSize;                    /* Required file size */
         3401  +    i64 szChunk;                  /* Chunk size */
  3400   3402       struct stat buf;              /* Used to hold return values of fstat() */
  3401   3403      
  3402   3404       if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;
  3403   3405   
  3404         -    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
         3406  +    szChunk = pFile->szChunk;
         3407  +    if( szChunk==0 ){
         3408  +      nSize = nByte;
         3409  +    }else{
         3410  +      nSize = ((nByte+szChunk-1) / szChunk) * szChunk;
         3411  +    }
  3405   3412       if( nSize>(i64)buf.st_size ){
  3406   3413   
  3407   3414   #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
  3408   3415         /* The code below is handling the return value of osFallocate() 
  3409   3416         ** correctly. posix_fallocate() is defined to "returns zero on success, 
  3410   3417         ** or an error number on  failure". See the manpage for details. */
  3411   3418         int err;
................................................................................
  3440   3447     return SQLITE_OK;
  3441   3448   }
  3442   3449   
  3443   3450   /*
  3444   3451   ** Information and control of an open file handle.
  3445   3452   */
  3446   3453   static int unixFileControl(sqlite3_file *id, int op, void *pArg){
         3454  +  unixFile *pFile = (unixFile*)id;
  3447   3455     switch( op ){
  3448   3456       case SQLITE_FCNTL_LOCKSTATE: {
  3449         -      *(int*)pArg = ((unixFile*)id)->eFileLock;
         3457  +      *(int*)pArg = pFile->eFileLock;
  3450   3458         return SQLITE_OK;
  3451   3459       }
  3452   3460       case SQLITE_LAST_ERRNO: {
  3453         -      *(int*)pArg = ((unixFile*)id)->lastErrno;
         3461  +      *(int*)pArg = pFile->lastErrno;
  3454   3462         return SQLITE_OK;
  3455   3463       }
  3456   3464       case SQLITE_FCNTL_CHUNK_SIZE: {
  3457         -      ((unixFile*)id)->szChunk = *(int *)pArg;
         3465  +      pFile->szChunk = *(int *)pArg;
  3458   3466         return SQLITE_OK;
  3459   3467       }
  3460   3468       case SQLITE_FCNTL_SIZE_HINT: {
  3461         -      return fcntlSizeHint((unixFile *)id, *(i64 *)pArg);
         3469  +      return fcntlSizeHint(pFile, *(i64 *)pArg);
         3470  +    }
         3471  +    case SQLITE_FCNTL_PERSIST_WAL: {
         3472  +      int bPersist = *(int*)pArg;
         3473  +      if( bPersist<0 ){
         3474  +        *(int*)pArg = (pFile->ctrlFlags & UNIXFILE_PERSIST_WAL)!=0;
         3475  +      }else if( bPersist==0 ){
         3476  +        pFile->ctrlFlags &= ~UNIXFILE_PERSIST_WAL;
         3477  +      }else{
         3478  +        pFile->ctrlFlags |= UNIXFILE_PERSIST_WAL;
         3479  +      }
         3480  +      return SQLITE_OK;
  3462   3481       }
  3463   3482   #ifndef NDEBUG
  3464   3483       /* The pager calls this method to signal that it has done
  3465   3484       ** a rollback and that the database is therefore unchanged and
  3466   3485       ** it hence it is OK for the transaction change counter to be
  3467   3486       ** unchanged.
  3468   3487       */
................................................................................
  4779   4798     ** almost certain that an open() call on the same path will also fail.
  4780   4799     ** For this reason, if an error occurs in the stat() call here, it is
  4781   4800     ** ignored and -1 is returned. The caller will try to open a new file
  4782   4801     ** descriptor on the same path, fail, and return an error to SQLite.
  4783   4802     **
  4784   4803     ** Even if a subsequent open() call does succeed, the consequences of
  4785   4804     ** not searching for a resusable file descriptor are not dire.  */
  4786         -  if( 0==stat(zPath, &sStat) ){
         4805  +  if( 0==osStat(zPath, &sStat) ){
  4787   4806       unixInodeInfo *pInode;
  4788   4807   
  4789   4808       unixEnterMutex();
  4790   4809       pInode = inodeList;
  4791   4810       while( pInode && (pInode->fileId.dev!=sStat.st_dev
  4792   4811                        || pInode->fileId.ino!=sStat.st_ino) ){
  4793   4812          pInode = pInode->pNext;
................................................................................
  4855   4874       */
  4856   4875       nDb = sqlite3Strlen30(zPath) - 1; 
  4857   4876       while( nDb>0 && zPath[nDb]!='-' ) nDb--;
  4858   4877       if( nDb==0 ) return SQLITE_OK;
  4859   4878       memcpy(zDb, zPath, nDb);
  4860   4879       zDb[nDb] = '\0';
  4861   4880   
  4862         -    if( 0==stat(zDb, &sStat) ){
         4881  +    if( 0==osStat(zDb, &sStat) ){
  4863   4882         *pMode = sStat.st_mode & 0777;
  4864   4883       }else{
  4865   4884         rc = SQLITE_IOERR_FSTAT;
  4866   4885       }
  4867   4886     }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
  4868   4887       *pMode = 0600;
  4869   4888     }
................................................................................
  5200   5219   
  5201   5220       default:
  5202   5221         assert(!"Invalid flags argument");
  5203   5222     }
  5204   5223     *pResOut = (osAccess(zPath, amode)==0);
  5205   5224     if( flags==SQLITE_ACCESS_EXISTS && *pResOut ){
  5206   5225       struct stat buf;
  5207         -    if( 0==stat(zPath, &buf) && buf.st_size==0 ){
         5226  +    if( 0==osStat(zPath, &buf) && buf.st_size==0 ){
  5208   5227         *pResOut = 0;
  5209   5228       }
  5210   5229     }
  5211   5230     return SQLITE_OK;
  5212   5231   }
  5213   5232   
  5214   5233   

Changes to src/os_win.c.

    98     98   ** portability layer.
    99     99   */
   100    100   typedef struct winFile winFile;
   101    101   struct winFile {
   102    102     const sqlite3_io_methods *pMethod; /*** Must be first ***/
   103    103     sqlite3_vfs *pVfs;      /* The VFS used to open this file */
   104    104     HANDLE h;               /* Handle for accessing the file */
   105         -  unsigned char locktype; /* Type of lock currently held on this file */
          105  +  u8 locktype;            /* Type of lock currently held on this file */
   106    106     short sharedLockByte;   /* Randomly chosen byte used as a shared lock */
          107  +  u8 bPersistWal;         /* True to persist WAL files */
   107    108     DWORD lastErrno;        /* The Windows errno from the last I/O error */
   108    109     DWORD sectorSize;       /* Sector size of the device file is on */
   109    110     winShm *pShm;           /* Instance of shared memory on this file */
   110    111     const char *zPath;      /* Full pathname of this file */
   111    112     int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */
   112    113   #if SQLITE_OS_WINCE
   113    114     WCHAR *zDeleteOnClose;  /* Name of file to delete when closing */
................................................................................
  1331   1332     return rc;
  1332   1333   }
  1333   1334   
  1334   1335   /*
  1335   1336   ** Control and query of the open file handle.
  1336   1337   */
  1337   1338   static int winFileControl(sqlite3_file *id, int op, void *pArg){
         1339  +  winFile *pFile = (winFile*)id;
  1338   1340     switch( op ){
  1339   1341       case SQLITE_FCNTL_LOCKSTATE: {
  1340         -      *(int*)pArg = ((winFile*)id)->locktype;
         1342  +      *(int*)pArg = pFile->locktype;
  1341   1343         return SQLITE_OK;
  1342   1344       }
  1343   1345       case SQLITE_LAST_ERRNO: {
  1344         -      *(int*)pArg = (int)((winFile*)id)->lastErrno;
         1346  +      *(int*)pArg = (int)pFile->lastErrno;
  1345   1347         return SQLITE_OK;
  1346   1348       }
  1347   1349       case SQLITE_FCNTL_CHUNK_SIZE: {
  1348         -      ((winFile*)id)->szChunk = *(int *)pArg;
         1350  +      pFile->szChunk = *(int *)pArg;
  1349   1351         return SQLITE_OK;
  1350   1352       }
  1351   1353       case SQLITE_FCNTL_SIZE_HINT: {
  1352   1354         sqlite3_int64 sz = *(sqlite3_int64*)pArg;
  1353   1355         SimulateIOErrorBenign(1);
  1354   1356         winTruncate(id, sz);
  1355   1357         SimulateIOErrorBenign(0);
  1356   1358         return SQLITE_OK;
         1359  +    }
         1360  +    case SQLITE_FCNTL_PERSIST_WAL: {
         1361  +      int bPersist = *(int*)pArg;
         1362  +      if( bPersist<0 ){
         1363  +        *(int*)pArg = pFile->bPersistWal;
         1364  +      }else{
         1365  +        pFile->bPersistWal = bPersist!=0;
         1366  +      }
         1367  +      return SQLITE_OK;
  1357   1368       }
  1358   1369       case SQLITE_FCNTL_SYNC_OMITTED: {
  1359   1370         return SQLITE_OK;
  1360   1371       }
  1361   1372       case SQLITE_FCNTL_WIN32_AV_RETRY: {
  1362   1373         int *a = (int*)pArg;
  1363   1374         if( a[0]>0 ){
................................................................................
  2448   2459   
  2449   2460     SimulateIOError( return SQLITE_IOERR_ACCESS; );
  2450   2461     zConverted = convertUtf8Filename(zFilename);
  2451   2462     if( zConverted==0 ){
  2452   2463       return SQLITE_NOMEM;
  2453   2464     }
  2454   2465     if( isNT() ){
         2466  +    int cnt = 0;
  2455   2467       WIN32_FILE_ATTRIBUTE_DATA sAttrData;
  2456   2468       memset(&sAttrData, 0, sizeof(sAttrData));
  2457         -    if( GetFileAttributesExW((WCHAR*)zConverted,
         2469  +    while( !(rc = GetFileAttributesExW((WCHAR*)zConverted,
  2458   2470                                GetFileExInfoStandard, 
  2459         -                             &sAttrData) ){
         2471  +                             &sAttrData)) && retryIoerr(&cnt) ){}
         2472  +    if( rc ){
  2460   2473         /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
  2461   2474         ** as if it does not exist.
  2462   2475         */
  2463   2476         if(    flags==SQLITE_ACCESS_EXISTS
  2464   2477             && sAttrData.nFileSizeHigh==0 
  2465   2478             && sAttrData.nFileSizeLow==0 ){
  2466   2479           attr = INVALID_FILE_ATTRIBUTES;
  2467   2480         }else{
  2468   2481           attr = sAttrData.dwFileAttributes;
  2469   2482         }
  2470   2483       }else{
         2484  +      logIoerr(cnt);
  2471   2485         if( GetLastError()!=ERROR_FILE_NOT_FOUND ){
  2472   2486           winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename);
  2473   2487           free(zConverted);
  2474   2488           return SQLITE_IOERR_ACCESS;
  2475   2489         }else{
  2476   2490           attr = INVALID_FILE_ATTRIBUTES;
  2477   2491         }
................................................................................
  2488   2502     free(zConverted);
  2489   2503     switch( flags ){
  2490   2504       case SQLITE_ACCESS_READ:
  2491   2505       case SQLITE_ACCESS_EXISTS:
  2492   2506         rc = attr!=INVALID_FILE_ATTRIBUTES;
  2493   2507         break;
  2494   2508       case SQLITE_ACCESS_READWRITE:
  2495         -      rc = (attr & FILE_ATTRIBUTE_READONLY)==0;
         2509  +      rc = attr!=INVALID_FILE_ATTRIBUTES &&
         2510  +             (attr & FILE_ATTRIBUTE_READONLY)==0;
  2496   2511         break;
  2497   2512       default:
  2498   2513         assert(!"Invalid flags argument");
  2499   2514     }
  2500   2515     *pResOut = rc;
  2501   2516     return SQLITE_OK;
  2502   2517   }

Changes to src/sqlite.h.in.

   748    748   ** to be adjusted.  The values are changed for all database connections
   749    749   ** within the same process.  The argument is a pointer to an array of two
   750    750   ** integers where the first integer i the new retry count and the second
   751    751   ** integer is the delay.  If either integer is negative, then the setting
   752    752   ** is not changed but instead the prior value of that setting is written
   753    753   ** into the array entry, allowing the current retry settings to be
   754    754   ** interrogated.  The zDbName parameter is ignored.
          755  +**
          756  +** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
          757  +** persistent [WAL | Write AHead Log] setting.  By default, the auxiliary
          758  +** write ahead log and shared memory files used for transaction control
          759  +** are automatically deleted when the latest connection to the database
          760  +** closes.  Setting persistent WAL mode causes those files to persist after
          761  +** close.  Persisting the files is useful when other processes that do not
          762  +** have write permission on the directory containing the database file want
          763  +** to read the database file, as the WAL and shared memory files must exist
          764  +** in order for the database to be readable.  The fourth parameter to
          765  +** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
          766  +** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
          767  +** WAL mode.  If the integer is -1, then it is overwritten with the current
          768  +** WAL persistence setting.
   755    769   ** 
   756    770   */
   757    771   #define SQLITE_FCNTL_LOCKSTATE        1
   758    772   #define SQLITE_GET_LOCKPROXYFILE      2
   759    773   #define SQLITE_SET_LOCKPROXYFILE      3
   760    774   #define SQLITE_LAST_ERRNO             4
   761    775   #define SQLITE_FCNTL_SIZE_HINT        5
   762    776   #define SQLITE_FCNTL_CHUNK_SIZE       6
   763    777   #define SQLITE_FCNTL_FILE_POINTER     7
   764    778   #define SQLITE_FCNTL_SYNC_OMITTED     8
   765    779   #define SQLITE_FCNTL_WIN32_AV_RETRY   9
          780  +#define SQLITE_FCNTL_PERSIST_WAL     10
   766    781   
   767    782   /*
   768    783   ** CAPI3REF: Mutex Handle
   769    784   **
   770    785   ** The mutex module within SQLite defines [sqlite3_mutex] to be an
   771    786   ** abstract type for a mutex object.  The SQLite core never looks
   772    787   ** at the internal representation of an [sqlite3_mutex].  It only

Changes to src/test1.c.

  5125   5125     if( Tcl_GetIntFromObj(interp, objv[3], &a[1]) ) return TCL_ERROR;
  5126   5126     rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_AV_RETRY, (void*)a);
  5127   5127     sqlite3_snprintf(sizeof(z), z, "%d %d %d", rc, a[0], a[1]);
  5128   5128     Tcl_AppendResult(interp, z, (char*)0);
  5129   5129     return TCL_OK;  
  5130   5130   }
  5131   5131   
         5132  +/*
         5133  +** tclcmd:   file_control_persist_wal DB PERSIST-FLAG
         5134  +**
         5135  +** This TCL command runs the sqlite3_file_control interface with
         5136  +** the SQLITE_FCNTL_PERSIST_WAL opcode.
         5137  +*/
         5138  +static int file_control_persist_wal(
         5139  +  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
         5140  +  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
         5141  +  int objc,              /* Number of arguments */
         5142  +  Tcl_Obj *CONST objv[]  /* Command arguments */
         5143  +){
         5144  +  sqlite3 *db;
         5145  +  int rc;
         5146  +  int bPersist;
         5147  +  char z[100];
         5148  +
         5149  +  if( objc!=3 ){
         5150  +    Tcl_AppendResult(interp, "wrong # args: should be \"",
         5151  +        Tcl_GetStringFromObj(objv[0], 0), " DB FLAG", 0);
         5152  +    return TCL_ERROR;
         5153  +  }
         5154  +  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){
         5155  +    return TCL_ERROR;
         5156  +  }
         5157  +  if( Tcl_GetIntFromObj(interp, objv[2], &bPersist) ) return TCL_ERROR;
         5158  +  rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, (void*)&bPersist);
         5159  +  sqlite3_snprintf(sizeof(z), z, "%d %d", rc, bPersist);
         5160  +  Tcl_AppendResult(interp, z, (char*)0);
         5161  +  return TCL_OK;  
         5162  +}
         5163  +
  5132   5164   
  5133   5165   /*
  5134   5166   ** tclcmd:   sqlite3_vfs_list
  5135   5167   **
  5136   5168   **   Return a tcl list containing the names of all registered vfs's.
  5137   5169   */
  5138   5170   static int vfs_list(
................................................................................
  5924   5956        { "vfs_reregister_all",         vfs_reregister_all,  0   },
  5925   5957        { "file_control_test",          file_control_test,   0   },
  5926   5958        { "file_control_lasterrno_test", file_control_lasterrno_test,  0   },
  5927   5959        { "file_control_lockproxy_test", file_control_lockproxy_test,  0   },
  5928   5960        { "file_control_chunksize_test", file_control_chunksize_test,  0   },
  5929   5961        { "file_control_sizehint_test",  file_control_sizehint_test,   0   },
  5930   5962        { "file_control_win32_av_retry", file_control_win32_av_retry,  0   },
         5963  +     { "file_control_persist_wal",    file_control_persist_wal,     0   },
  5931   5964        { "sqlite3_vfs_list",           vfs_list,     0   },
  5932   5965        { "sqlite3_create_function_v2", test_create_function_v2, 0 },
  5933   5966   
  5934   5967        /* Functions from os.h */
  5935   5968   #ifndef SQLITE_OMIT_UTF16
  5936   5969        { "add_test_collate",        test_collate, 0            },
  5937   5970        { "add_test_collate_needed", test_collate_needed, 0     },

Changes to src/test_multiplex.c.

   410    410   static void multiplexSubClose(
   411    411     multiplexGroup *pGroup,
   412    412     int iChunk,
   413    413     sqlite3_vfs *pOrigVfs
   414    414   ){
   415    415     sqlite3_file *pSubOpen = pGroup->aReal[iChunk].p;
   416    416     if( pSubOpen ){
   417         -    if( pOrigVfs ) pOrigVfs->xDelete(pOrigVfs, pGroup->aReal[iChunk].z, 0);
   418    417       pSubOpen->pMethods->xClose(pSubOpen);
          418  +    if( pOrigVfs ) pOrigVfs->xDelete(pOrigVfs, pGroup->aReal[iChunk].z, 0);
   419    419       sqlite3_free(pGroup->aReal[iChunk].p);
   420    420     }
   421    421     sqlite3_free(pGroup->aReal[iChunk].z);
   422    422     memset(&pGroup->aReal[iChunk], 0, sizeof(pGroup->aReal[iChunk]));
   423    423   }
   424    424   
   425    425   /*

Changes to src/vdbe.c.

  1033   1033       assert( pOut<=&aMem[p->nMem] );
  1034   1034       assert( pIn1<=&aMem[p->nMem] );
  1035   1035       assert( memIsValid(pIn1) );
  1036   1036       memAboutToChange(p, pOut);
  1037   1037       zMalloc = pOut->zMalloc;
  1038   1038       pOut->zMalloc = 0;
  1039   1039       sqlite3VdbeMemMove(pOut, pIn1);
         1040  +#ifdef SQLITE_DEBUG
         1041  +    if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<&aMem[p1+pOp->p3] ){
         1042  +      pOut->pScopyFrom += p1 - pOp->p2;
         1043  +    }
         1044  +#endif
  1040   1045       pIn1->zMalloc = zMalloc;
  1041   1046       REGISTER_TRACE(p2++, pOut);
  1042   1047       pIn1++;
  1043   1048       pOut++;
  1044   1049     }
  1045   1050     break;
  1046   1051   }

Changes to src/wal.c.

  1800   1800       ** the database. In this case checkpoint the database and unlink both
  1801   1801       ** the wal and wal-index files.
  1802   1802       **
  1803   1803       ** The EXCLUSIVE lock is not released before returning.
  1804   1804       */
  1805   1805       rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE);
  1806   1806       if( rc==SQLITE_OK ){
         1807  +      int bPersistWal = -1;
  1807   1808         if( pWal->exclusiveMode==WAL_NORMAL_MODE ){
  1808   1809           pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;
  1809   1810         }
  1810   1811         rc = sqlite3WalCheckpoint(
  1811   1812             pWal, SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0
  1812   1813         );
  1813         -      if( rc==SQLITE_OK ){
         1814  +      sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersistWal);
         1815  +      if( rc==SQLITE_OK && bPersistWal!=1 ){
  1814   1816           isDelete = 1;
  1815   1817         }
  1816   1818       }
  1817   1819   
  1818   1820       walIndexClose(pWal, isDelete);
  1819   1821       sqlite3OsClose(pWal->pWalFd);
  1820   1822       if( isDelete ){

Changes to src/where.c.

  2138   2138     ** to this virtual table */
  2139   2139     for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
  2140   2140       if( pTerm->leftCursor != pSrc->iCursor ) continue;
  2141   2141       assert( (pTerm->eOperator&(pTerm->eOperator-1))==0 );
  2142   2142       testcase( pTerm->eOperator==WO_IN );
  2143   2143       testcase( pTerm->eOperator==WO_ISNULL );
  2144   2144       if( pTerm->eOperator & (WO_IN|WO_ISNULL) ) continue;
         2145  +    if( pTerm->wtFlags & TERM_VNULL ) continue;
  2145   2146       nTerm++;
  2146   2147     }
  2147   2148   
  2148   2149     /* If the ORDER BY clause contains only columns in the current 
  2149   2150     ** virtual table then allocate space for the aOrderBy part of
  2150   2151     ** the sqlite3_index_info structure.
  2151   2152     */
................................................................................
  2188   2189   
  2189   2190     for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
  2190   2191       if( pTerm->leftCursor != pSrc->iCursor ) continue;
  2191   2192       assert( (pTerm->eOperator&(pTerm->eOperator-1))==0 );
  2192   2193       testcase( pTerm->eOperator==WO_IN );
  2193   2194       testcase( pTerm->eOperator==WO_ISNULL );
  2194   2195       if( pTerm->eOperator & (WO_IN|WO_ISNULL) ) continue;
         2196  +    if( pTerm->wtFlags & TERM_VNULL ) continue;
  2195   2197       pIdxCons[j].iColumn = pTerm->u.leftColumn;
  2196   2198       pIdxCons[j].iTermOffset = i;
  2197   2199       pIdxCons[j].op = (u8)pTerm->eOperator;
  2198   2200       /* The direct assignment in the previous line is possible only because
  2199   2201       ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical.  The
  2200   2202       ** following asserts verify this fact. */
  2201   2203       assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ );

Changes to test/permutations.test.

   519    519     e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test
   520    520     fts3snippet.test
   521    521   
   522    522     # Exclude test scripts that use tcl IO to access journal files or count
   523    523     # the number of fsync() calls.
   524    524     pager.test exclusive.test jrnlmode.test sync.test misc1.test 
   525    525     journal1.test conflict.test crash8.test tkt3457.test io.test
   526         -  journal3.test
          526  +  journal3.test 8_3_names.test
   527    527   
   528    528     pager1.test async4.test corrupt.test filefmt.test pager2.test
   529    529     corrupt5.test corruptA.test pageropt.test
   530    530   
   531    531     # Exclude stmt.test, which expects sub-journals to use temporary files.
   532    532     stmt.test
   533    533   
   534    534     # WAL mode is different.
   535         -  wal* tkt-2d1a5c67d.test
          535  +  wal* tkt-2d1a5c67d.test backcompat.test
   536    536   }]
   537    537   
   538    538   ifcapable mem3 {
   539    539     test_suite "memsys3" -description {
   540    540       Run tests using the allocator in mem3.c.
   541    541     } -files [test_set $::allquicktests -exclude {
   542    542       autovacuum.test           delete3.test              manydb.test
................................................................................
   725    725   } -initialize {
   726    726     catch {db close}
   727    727     register_jt_vfs -default ""
   728    728   } -shutdown {
   729    729     unregister_jt_vfs
   730    730   } -files [test_set $::allquicktests -exclude {
   731    731     wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test 
   732         -  async4.test bigfile.test
          732  +  async4.test bigfile.test backcompat.test
   733    733   }]
   734    734   
   735    735   if {[info commands register_demovfs] != ""} {
   736    736     test_suite "demovfs" -description {
   737    737       Check that the demovfs (code in test_demovfs.c) more or less works.
   738    738     } -initialize {
   739    739       register_demovfs
................................................................................
   868    868         if {[llength $argv]>1} { set extra [list -files [lrange $argv 1 end]] }
   869    869         eval run_tests $suite $::testspec($suite) $extra
   870    870       }
   871    871     }
   872    872     main $argv
   873    873     finish_test
   874    874   }
   875         -

Added test/tkt-d635236375.test.

            1  +# 2011 August 3
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this file is testing that bug [d63523637517386191d634e]
           13  +# has been fixed.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +
           19  +set ::testprefix tkt-d635236375
           20  +
           21  +do_test 1.0 {
           22  +  execsql {
           23  +    CREATE TABLE t1(id1 INTEGER PRIMARY KEY);
           24  +    INSERT INTO t1 VALUES(9999);
           25  +    CREATE TABLE t2(id2 INTEGER PRIMARY KEY);
           26  +    INSERT INTO t2 VALUES(12345);
           27  +    INSERT INTO t2 VALUES(54321);
           28  +    SELECT DISTINCT id1 AS x, id1 AS y FROM t1, t2;
           29  +  }
           30  +} {9999 9999}
           31  +do_test 1.1 {
           32  +  execsql {
           33  +    SELECT count(*) FROM t1, t2 GROUP BY id1, id1;
           34  +  }
           35  +} {2}
           36  +
           37  +
           38  +finish_test

Added test/vtabF.test.

            1  +# 2011 Aug 1
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library. 
           12  +# This file checks to make sure IS NOT NULL constraints work on
           13  +# virtual tables.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +
           19  +ifcapable !vtab||!schema_pragmas { finish_test ; return }
           20  +
           21  +# Register the echo module
           22  +register_echo_module [sqlite3_connection_pointer db]
           23  +
           24  +do_test vtabE-1.1 {
           25  +  execsql {
           26  +    CREATE TABLE t1(a, b);
           27  +    CREATE INDEX i1 ON t1(a);
           28  +    CREATE INDEX i2 ON t1(b);
           29  +    INSERT INTO t1 VALUES(10,110);
           30  +    INSERT INTO t1 VALUES(11,111);
           31  +    INSERT INTO t1 SELECT a+2, b+2 FROM t1;
           32  +    INSERT INTO t1 SELECT null, b+4 FROM t1;
           33  +    INSERT INTO t1 SELECT null, b+8 FROM t1;
           34  +    INSERT INTO t1 SELECT null, b+16 FROM t1;
           35  +    ANALYZE;
           36  +    CREATE VIRTUAL TABLE tv1 USING echo(t1);
           37  +    SELECT b FROM t1 WHERE a IS NOT NULL;
           38  +  }
           39  +} {110 111 112 113}
           40  +do_test vtabE-1.2 {
           41  +  execsql {SELECT b FROM tv1 WHERE a IS NOT NULL}
           42  +} {110 111 112 113}
           43  +
           44  +
           45  +finish_test

Changes to test/wal5.test.

   231    231       } {}
   232    232       do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5}
   233    233       do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
   234    234       do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}
   235    235       do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
   236    236       do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
   237    237       do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}
   238         -    if {$tcl_platform(platform) == "windows"} {
   239         -        # on unix, the size_hint is a no-op if no chunk size is set.
   240         -        # the windows implementation does not have a similar check,
   241         -        # and because of this, the db file size has an extra page.
   242         -        do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
   243         -    } {
   244         -        do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
   245         -    }
          238  +    do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
   246    239     }
   247    240   
   248    241     # Check that checkpoints block on the correct locks. And respond correctly
   249    242     # if they cannot obtain those locks. There are three locks that a checkpoint
   250    243     # may block on (in the following order):
   251    244     #
   252    245     #   1. The writer lock: FULL and RESTART checkpoints block until any writer
................................................................................
   346    339   
   347    340       do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}
   348    341     }
   349    342   }
   350    343   
   351    344   
   352    345   finish_test
   353         -

Added test/walpersist.test.

            1  +# 2011 July 26
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# This file contains tests for using WAL with persistent WAL file mode.
           13  +#
           14  +
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +source $testdir/lock_common.tcl
           18  +set ::testprefix walpersist
           19  +
           20  +do_test walpersist-1.0 {
           21  +  db eval {
           22  +    PRAGMA journal_mode=WAL;
           23  +    CREATE TABLE t1(a);
           24  +    INSERT INTO t1 VALUES(randomblob(5000));
           25  +  }
           26  +  file exists test.db-wal
           27  +} {1}
           28  +do_test walpersist-1.1 {
           29  +  file exists test.db-shm
           30  +} {1}
           31  +do_test walpersist-1.2 {
           32  +  db close
           33  +  list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
           34  +} {1 0 0}
           35  +do_test walpersist-1.3 {
           36  +  sqlite3 db test.db
           37  +  db eval {SELECT length(a) FROM t1}
           38  +} {5000}
           39  +do_test walpersist-1.4 {
           40  +  list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
           41  +} {1 1 1}
           42  +do_test walpersist-1.5 {
           43  +  file_control_persist_wal db -1
           44  +} {0 0}
           45  +do_test walpersist-1.6 {
           46  +  file_control_persist_wal db 1
           47  +} {0 1}
           48  +do_test walpersist-1.7 {
           49  +  file_control_persist_wal db -1
           50  +} {0 1}
           51  +do_test walpersist-1.8 {
           52  +  file_control_persist_wal db 0
           53  +} {0 0}
           54  +do_test walpersist-1.9 {
           55  +  file_control_persist_wal db -1
           56  +} {0 0}
           57  +do_test walpersist-1.10 {
           58  +  file_control_persist_wal db 1
           59  +} {0 1}
           60  +do_test walpersist-1.11 {
           61  +  db close
           62  +  list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
           63  +} {1 1 1}
           64  +
           65  +  
           66  +
           67  +
           68  +finish_test

Changes to test/win32lock.test.

    53     53          set ::msg
    54     54       } {disk I/O error}
    55     55       break
    56     56     } else {
    57     57       do_test win32lock-1.2-$delay1 {
    58     58          set ::msg
    59     59       } {1 100000 2 50000 3 25000 4 12500}
    60         -    if {$::log!=""} {
           60  +    if {[info exists ::log] && $::log!=""} {
    61     61         do_test win32lock-1.2-$delay1-log1 {
    62     62           regsub {\d+} $::log # x
    63     63           set x
    64     64         } {{delayed #ms for lock/sharing conflict}}
    65     65       }
    66     66       incr delay1 50
    67     67     }