/ Check-in [cca79fdc]
Login

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

Overview
Comment:Enable the RBU extension to compile cleanly on Windows using MSVC.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cca79fdc3dff65907c2a59369057265b4512058f
User & Date: mistachkin 2015-07-24 21:19:25
Context
2015-07-24
23:28
Fix the zeroblob.test script so that it works even on builds where the SQLITE_MAX_LENGTH has been raised to 2147483645. check-in: db129149 user: drh tags: trunk
22:21
Merge test improvements and minor fixes from trunk. check-in: 0298a9a7 user: drh tags: sessions
21:19
Enable the RBU extension to compile cleanly on Windows using MSVC. check-in: cca79fdc user: mistachkin tags: trunk
20:43
For Windows CE, a different header is required for the byteswap intrinsics. check-in: 2d572b8c user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rbu/rbu.c.

    61     61     }
    62     62   }
    63     63   
    64     64   int main(int argc, char **argv){
    65     65     int i;
    66     66     const char *zTarget;            /* Target database to apply RBU to */
    67     67     const char *zRbu;               /* Database containing RBU */
           68  +  char zBuf[200];                 /* Buffer for printf() */
    68     69     char *zErrmsg;                  /* Error message, if any */
    69     70     sqlite3rbu *pRbu;               /* RBU handle */
    70     71     int nStep = 0;                  /* Maximum number of step() calls */
    71     72     int rc;
    72     73     sqlite3_int64 nProgress = 0;
    73     74   
    74     75     /* Process command line arguments. Following this block local variables 
................................................................................
    94     95     for(i=0; (nStep<=0 || i<nStep) && sqlite3rbu_step(pRbu)==SQLITE_OK; i++);
    95     96     nProgress = sqlite3rbu_progress(pRbu);
    96     97     rc = sqlite3rbu_close(pRbu, &zErrmsg);
    97     98   
    98     99     /* Let the user know what happened. */
    99    100     switch( rc ){
   100    101       case SQLITE_OK:
   101         -      fprintf(stdout, 
          102  +      sqlite3_snprintf(sizeof(zBuf), zBuf,
   102    103             "SQLITE_OK: rbu update incomplete (%lld operations so far)\n",
   103    104             nProgress
   104    105         );
          106  +      fprintf(stdout, zBuf);
   105    107         break;
   106    108   
   107    109       case SQLITE_DONE:
   108         -      fprintf(stdout, 
          110  +      sqlite3_snprintf(sizeof(zBuf), zBuf,
   109    111             "SQLITE_DONE: rbu update completed (%lld operations)\n",
   110    112             nProgress
   111    113         );
          114  +      fprintf(stdout, zBuf);
   112    115         break;
   113    116   
   114    117       default:
   115    118         fprintf(stderr, "error=%d: %s\n", rc, zErrmsg);
   116    119         break;
   117    120     }
   118    121   
   119    122     sqlite3_free(zErrmsg);
   120    123     return (rc==SQLITE_OK || rc==SQLITE_DONE) ? 0 : 1;
   121    124   }
   122    125   

Changes to ext/rbu/sqlite3rbu.c.

    79     79   **  update database than is strictly necessary.
    80     80   ** 
    81     81   */
    82     82   
    83     83   #include <assert.h>
    84     84   #include <string.h>
    85     85   #include <stdio.h>
    86         -#include <unistd.h>
           86  +
           87  +#if !defined(_WIN32)
           88  +#  include <unistd.h>
           89  +#endif
    87     90   
    88     91   #include "sqlite3.h"
    89     92   
    90     93   #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU)
    91     94   #include "sqlite3rbu.h"
    92     95   
    93     96   /* Maximum number of prepared UPDATE statements held by this module */
................................................................................
   616    619   **
   617    620   ** If an error occurs, an error code and error message is stored in the
   618    621   ** RBU handle. If an error has already occurred when this function is
   619    622   ** called, it is a no-op.
   620    623   */
   621    624   static int rbuMPrintfExec(sqlite3rbu *p, sqlite3 *db, const char *zFmt, ...){
   622    625     va_list ap;
          626  +  char *zSql;
   623    627     va_start(ap, zFmt);
   624         -  char *zSql = sqlite3_vmprintf(zFmt, ap);
          628  +  zSql = sqlite3_vmprintf(zFmt, ap);
   625    629     if( p->rc==SQLITE_OK ){
   626    630       if( zSql==0 ){
   627    631         p->rc = SQLITE_NOMEM;
   628    632       }else{
   629    633         p->rc = sqlite3_exec(db, zSql, 0, 0, &p->zErrmsg);
   630    634       }
   631    635     }
................................................................................
  2636   2640   */
  2637   2641   static void rbuCreateVfs(sqlite3rbu *p){
  2638   2642     int rnd;
  2639   2643     char zRnd[64];
  2640   2644   
  2641   2645     assert( p->rc==SQLITE_OK );
  2642   2646     sqlite3_randomness(sizeof(int), (void*)&rnd);
  2643         -  sprintf(zRnd, "rbu_vfs_%d", rnd);
         2647  +  sqlite3_snprintf(sizeof(zRnd), zRnd, "rbu_vfs_%d", rnd);
  2644   2648     p->rc = sqlite3rbu_create_vfs(zRnd, 0);
  2645   2649     if( p->rc==SQLITE_OK ){
  2646   2650       sqlite3_vfs *pVfs = sqlite3_vfs_find(zRnd);
  2647   2651       assert( pVfs );
  2648   2652       p->zVfsName = pVfs->zName;
  2649   2653     }
  2650   2654   }
................................................................................
  3521   3525   }
  3522   3526   
  3523   3527   /*
  3524   3528   ** Close the dynamic library handle pHandle.
  3525   3529   */
  3526   3530   static void rbuVfsDlClose(sqlite3_vfs *pVfs, void *pHandle){
  3527   3531     sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;
  3528         -  return pRealVfs->xDlClose(pRealVfs, pHandle);
         3532  +  pRealVfs->xDlClose(pRealVfs, pHandle);
  3529   3533   }
  3530   3534   #endif /* SQLITE_OMIT_LOAD_EXTENSION */
  3531   3535   
  3532   3536   /*
  3533   3537   ** Populate the buffer pointed to by zBufOut with nByte bytes of 
  3534   3538   ** random data.
  3535   3539   */