/ Check-in [45acf6a8]
Login

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

Overview
Comment:Merge updates from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | winViewFlush
Files: files | file ages | folders
SHA1: 45acf6a85150839d591316418dad59ae20ce3aa4
User & Date: mistachkin 2015-03-27 18:22:01
Context
2015-03-31
19:40
On windows, flush the mapping view when syncing content to disk. check-in: a828e73d user: drh tags: trunk
2015-03-27
18:22
Merge updates from trunk. Closed-Leaf check-in: 45acf6a8 user: mistachkin tags: winViewFlush
18:20
Enhancements to OSTRACE usage in the Win32 VFS. check-in: ab580029 user: mistachkin tags: trunk
2015-03-26
23:36
When syncing a memory mapped file on Windows, flush the mapped view as well. check-in: df204049 user: mistachkin tags: winViewFlush
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.msc.

   327    327   CORE_CCONV_OPTS =
   328    328   SHELL_CCONV_OPTS =
   329    329   !ENDIF
   330    330   
   331    331   # These are additional compiler options used for the core library.
   332    332   #
   333    333   !IFNDEF CORE_COMPILE_OPTS
   334         -!IF $(USE_STDCALL)!=0
          334  +!IF $(DYNAMIC_SHELL)!=0
   335    335   CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
   336    336   !ELSE
   337    337   CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
   338    338   !ENDIF
   339    339   !ENDIF
   340    340   
   341    341   # These are the additional targets that the core library should depend on
   342    342   # when linking.
   343    343   #
   344    344   !IFNDEF CORE_LINK_DEP
   345         -!IF $(USE_STDCALL)!=0
          345  +!IF $(DYNAMIC_SHELL)!=0
   346    346   CORE_LINK_DEP =
   347    347   !ELSE
   348    348   CORE_LINK_DEP = sqlite3.def
   349    349   !ENDIF
   350    350   !ENDIF
   351    351   
   352    352   # These are additional linker options used for the core library.
   353    353   #
   354    354   !IFNDEF CORE_LINK_OPTS
   355         -!IF $(USE_STDCALL)!=0
          355  +!IF $(DYNAMIC_SHELL)!=0
   356    356   CORE_LINK_OPTS =
   357    357   !ELSE
   358    358   CORE_LINK_OPTS = /DEF:sqlite3.def
   359    359   !ENDIF
   360    360   !ENDIF
   361    361   
   362    362   # These are additional compiler options used for the shell executable.

Changes to src/main.c.

    58     58   #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
    59     59   /*
    60     60   ** If the following function pointer is not NULL and if
    61     61   ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
    62     62   ** I/O active are written using this function.  These messages
    63     63   ** are intended for debugging activity only.
    64     64   */
    65         -/* not-private */ void (*sqlite3IoTrace)(const char*, ...) = 0;
           65  +SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;
    66     66   #endif
    67     67   
    68     68   /*
    69     69   ** If the following global variable points to a string which is the
    70     70   ** name of a directory, then that directory will be used to store
    71     71   ** temporary files.
    72     72   **

Changes to src/os_win.c.

  2457   2457     winFile *pFile = (winFile*)id;
  2458   2458   
  2459   2459     assert( id!=0 );
  2460   2460   #ifndef SQLITE_OMIT_WAL
  2461   2461     assert( pFile->pShm==0 );
  2462   2462   #endif
  2463   2463     assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
  2464         -  OSTRACE(("CLOSE file=%p\n", pFile->h));
         2464  +  OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n",
         2465  +           osGetCurrentProcessId(), pFile, pFile->h));
  2465   2466   
  2466   2467   #if SQLITE_MAX_MMAP_SIZE>0
  2467   2468     winUnmapfile(pFile);
  2468   2469   #endif
  2469   2470   
  2470   2471     do{
  2471   2472       rc = osCloseHandle(pFile->h);
................................................................................
  2486   2487       sqlite3_free(pFile->zDeleteOnClose);
  2487   2488     }
  2488   2489   #endif
  2489   2490     if( rc ){
  2490   2491       pFile->h = NULL;
  2491   2492     }
  2492   2493     OpenCounter(-1);
  2493         -  OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
         2494  +  OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n",
         2495  +           osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
  2494   2496     return rc ? SQLITE_OK
  2495   2497               : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
  2496   2498                             "winClose", pFile->zPath);
  2497   2499   }
  2498   2500   
  2499   2501   /*
  2500   2502   ** Read data from a file into a buffer.  Return SQLITE_OK if all
................................................................................
  2514   2516     DWORD nRead;                    /* Number of bytes actually read from file */
  2515   2517     int nRetry = 0;                 /* Number of retrys */
  2516   2518   
  2517   2519     assert( id!=0 );
  2518   2520     assert( amt>0 );
  2519   2521     assert( offset>=0 );
  2520   2522     SimulateIOError(return SQLITE_IOERR_READ);
  2521         -  OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
         2523  +  OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
         2524  +           "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
  2522   2525              pFile->h, pBuf, amt, offset, pFile->locktype));
  2523   2526   
  2524   2527   #if SQLITE_MAX_MMAP_SIZE>0
  2525   2528     /* Deal with as much of this read request as possible by transfering
  2526   2529     ** data from the memory mapping using memcpy().  */
  2527   2530     if( offset<pFile->mmapSize ){
  2528   2531       if( offset+amt <= pFile->mmapSize ){
  2529   2532         memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
  2530         -      OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
         2533  +      OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
         2534  +               osGetCurrentProcessId(), pFile, pFile->h));
  2531   2535         return SQLITE_OK;
  2532   2536       }else{
  2533   2537         int nCopy = (int)(pFile->mmapSize - offset);
  2534   2538         memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
  2535   2539         pBuf = &((u8 *)pBuf)[nCopy];
  2536   2540         amt -= nCopy;
  2537   2541         offset += nCopy;
  2538   2542       }
  2539   2543     }
  2540   2544   #endif
  2541   2545   
  2542   2546   #if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
  2543   2547     if( winSeekFile(pFile, offset) ){
  2544         -    OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
         2548  +    OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
         2549  +             osGetCurrentProcessId(), pFile, pFile->h));
  2545   2550       return SQLITE_FULL;
  2546   2551     }
  2547   2552     while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
  2548   2553   #else
  2549   2554     memset(&overlapped, 0, sizeof(OVERLAPPED));
  2550   2555     overlapped.Offset = (LONG)(offset & 0xffffffff);
  2551   2556     overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
  2552   2557     while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
  2553   2558            osGetLastError()!=ERROR_HANDLE_EOF ){
  2554   2559   #endif
  2555   2560       DWORD lastErrno;
  2556   2561       if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
  2557   2562       pFile->lastErrno = lastErrno;
  2558         -    OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
         2563  +    OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n",
         2564  +             osGetCurrentProcessId(), pFile, pFile->h));
  2559   2565       return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
  2560   2566                          "winRead", pFile->zPath);
  2561   2567     }
  2562   2568     winLogIoerr(nRetry, __LINE__);
  2563   2569     if( nRead<(DWORD)amt ){
  2564   2570       /* Unread parts of the buffer must be zero-filled */
  2565   2571       memset(&((char*)pBuf)[nRead], 0, amt-nRead);
  2566         -    OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
         2572  +    OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n",
         2573  +             osGetCurrentProcessId(), pFile, pFile->h));
  2567   2574       return SQLITE_IOERR_SHORT_READ;
  2568   2575     }
  2569   2576   
  2570         -  OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
         2577  +  OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
         2578  +           osGetCurrentProcessId(), pFile, pFile->h));
  2571   2579     return SQLITE_OK;
  2572   2580   }
  2573   2581   
  2574   2582   /*
  2575   2583   ** Write data from a buffer into a file.  Return SQLITE_OK on success
  2576   2584   ** or some other error code on failure.
  2577   2585   */
................................................................................
  2586   2594     int nRetry = 0;                 /* Number of retries */
  2587   2595   
  2588   2596     assert( amt>0 );
  2589   2597     assert( pFile );
  2590   2598     SimulateIOError(return SQLITE_IOERR_WRITE);
  2591   2599     SimulateDiskfullError(return SQLITE_FULL);
  2592   2600   
  2593         -  OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
         2601  +  OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
         2602  +           "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
  2594   2603              pFile->h, pBuf, amt, offset, pFile->locktype));
  2595   2604   
  2596   2605   #if SQLITE_MAX_MMAP_SIZE>0
  2597   2606     /* Deal with as much of this write request as possible by transfering
  2598   2607     ** data from the memory mapping using memcpy().  */
  2599   2608     if( offset<pFile->mmapSize ){
  2600   2609       if( offset+amt <= pFile->mmapSize ){
  2601   2610         memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
  2602         -      OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
         2611  +      OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
         2612  +               osGetCurrentProcessId(), pFile, pFile->h));
  2603   2613         return SQLITE_OK;
  2604   2614       }else{
  2605   2615         int nCopy = (int)(pFile->mmapSize - offset);
  2606   2616         memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
  2607   2617         pBuf = &((u8 *)pBuf)[nCopy];
  2608   2618         amt -= nCopy;
  2609   2619         offset += nCopy;
................................................................................
  2658   2668         rc = 1;
  2659   2669       }
  2660   2670     }
  2661   2671   
  2662   2672     if( rc ){
  2663   2673       if(   ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
  2664   2674          || ( pFile->lastErrno==ERROR_DISK_FULL )){
  2665         -      OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
         2675  +      OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
         2676  +               osGetCurrentProcessId(), pFile, pFile->h));
  2666   2677         return winLogError(SQLITE_FULL, pFile->lastErrno,
  2667   2678                            "winWrite1", pFile->zPath);
  2668   2679       }
  2669         -    OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
         2680  +    OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n",
         2681  +             osGetCurrentProcessId(), pFile, pFile->h));
  2670   2682       return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
  2671   2683                          "winWrite2", pFile->zPath);
  2672   2684     }else{
  2673   2685       winLogIoerr(nRetry, __LINE__);
  2674   2686     }
  2675         -  OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
         2687  +  OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
         2688  +           osGetCurrentProcessId(), pFile, pFile->h));
  2676   2689     return SQLITE_OK;
  2677   2690   }
  2678   2691   
  2679   2692   /*
  2680   2693   ** Truncate an open file to a specified size
  2681   2694   */
  2682   2695   static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
  2683   2696     winFile *pFile = (winFile*)id;  /* File handle object */
  2684   2697     int rc = SQLITE_OK;             /* Return code for this function */
  2685   2698     DWORD lastErrno;
  2686   2699   
  2687   2700     assert( pFile );
  2688   2701     SimulateIOError(return SQLITE_IOERR_TRUNCATE);
  2689         -  OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
  2690         -           pFile->h, nByte, pFile->locktype));
         2702  +  OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
         2703  +           osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
  2691   2704   
  2692   2705     /* If the user has configured a chunk-size for this file, truncate the
  2693   2706     ** file so that it consists of an integer number of chunks (i.e. the
  2694   2707     ** actual file size after the operation may be larger than the requested
  2695   2708     ** size).
  2696   2709     */
  2697   2710     if( pFile->szChunk>0 ){
................................................................................
  2715   2728     ** use read() and write() to access data beyond this point from now on.
  2716   2729     */
  2717   2730     if( pFile->pMapRegion && nByte<pFile->mmapSize ){
  2718   2731       pFile->mmapSize = nByte;
  2719   2732     }
  2720   2733   #endif
  2721   2734   
  2722         -  OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
         2735  +  OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
         2736  +           osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
  2723   2737     return rc;
  2724   2738   }
  2725   2739   
  2726   2740   #ifdef SQLITE_TEST
  2727   2741   /*
  2728   2742   ** Count the number of fullsyncs and normal syncs.  This is used to test
  2729   2743   ** that syncs and fullsyncs are occuring at the right times.

Changes to src/shell.c.

   366    366   /*
   367    367   ** This routine works like printf in that its first argument is a
   368    368   ** format string and subsequent arguments are values to be substituted
   369    369   ** in place of % fields.  The result of formatting this string
   370    370   ** is written to iotrace.
   371    371   */
   372    372   #ifdef SQLITE_ENABLE_IOTRACE
   373         -static void iotracePrintf(const char *zFormat, ...){
          373  +static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
   374    374     va_list ap;
   375    375     char *z;
   376    376     if( iotrace==0 ) return;
   377    377     va_start(ap, zFormat);
   378    378     z = sqlite3_vmprintf(zFormat, ap);
   379    379     va_end(ap);
   380    380     fprintf(iotrace, "%s", z);
................................................................................
  3140   3140         fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n");
  3141   3141         rc = 1;
  3142   3142       }
  3143   3143     }else
  3144   3144   
  3145   3145   #ifdef SQLITE_ENABLE_IOTRACE
  3146   3146     if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
  3147         -    extern void (*sqlite3IoTrace)(const char*, ...);
         3147  +    SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
  3148   3148       if( iotrace && iotrace!=stdout ) fclose(iotrace);
  3149   3149       iotrace = 0;
  3150   3150       if( nArg<2 ){
  3151   3151         sqlite3IoTrace = 0;
  3152   3152       }else if( strcmp(azArg[1], "-")==0 ){
  3153   3153         sqlite3IoTrace = iotracePrintf;
  3154   3154         iotrace = stdout;
................................................................................
  3799   3799   
  3800   3800           case SQLITE_TESTCTRL_IMPOSTER:
  3801   3801             if( nArg==5 ){
  3802   3802               rc = sqlite3_test_control(testctrl, p->db, 
  3803   3803                             azArg[2],
  3804   3804                             integerValue(azArg[3]),
  3805   3805                             integerValue(azArg[4]));
         3806  +            fprintf(p->out, "%d (0x%08x)\n", rc, rc);
  3806   3807             }else{
  3807         -            fprintf(stderr,"Usage: .testctrl initmode dbName onoff tnum\n");
  3808         -            rc = 1;
         3808  +            fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
  3809   3809             }
  3810   3810             break;
  3811   3811   
  3812   3812           case SQLITE_TESTCTRL_BITVEC_TEST:         
  3813   3813           case SQLITE_TESTCTRL_FAULT_INSTALL:       
  3814   3814           case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: 
  3815   3815           case SQLITE_TESTCTRL_SCRATCHMALLOC:       

Changes to src/sqliteInt.h.

  3799   3799   ** If the SQLITE_ENABLE IOTRACE exists then the global variable
  3800   3800   ** sqlite3IoTrace is a pointer to a printf-like routine used to
  3801   3801   ** print I/O tracing messages. 
  3802   3802   */
  3803   3803   #ifdef SQLITE_ENABLE_IOTRACE
  3804   3804   # define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }
  3805   3805     void sqlite3VdbeIOTraceSql(Vdbe*);
  3806         -SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...);
         3806  +SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
  3807   3807   #else
  3808   3808   # define IOTRACE(A)
  3809   3809   # define sqlite3VdbeIOTraceSql(X)
  3810   3810   #endif
  3811   3811   
  3812   3812   /*
  3813   3813   ** These routines are available for the mem2.c debugging memory allocator