/ Check-in [fabe78c5]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix harmless compiler warnings in RBU and add RBU to the autoconf and windows makefiles.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fabe78c5d8ab353988f6fe0decacd651edc17ec2
User & Date: drh 2016-01-14 13:22:24
Context
2016-01-14
14:15
Fix compiler warnings in fts5. check-in: 5a343cc0 user: dan tags: trunk
13:22
Fix harmless compiler warnings in RBU and add RBU to the autoconf and windows makefiles. check-in: fabe78c5 user: drh tags: trunk
12:23
Fix harmless compiler warnings in sqldiff.c. check-in: 74808a79 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   175    175            func.lo global.lo hash.lo \
   176    176            icu.lo insert.lo journal.lo json1.lo legacy.lo loadext.lo \
   177    177            main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
   178    178            memjournal.lo \
   179    179            mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
   180    180            notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
   181    181            pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
   182         -         random.lo resolve.lo rowset.lo rtree.lo select.lo status.lo \
          182  +         random.lo resolve.lo rowset.lo rtree.lo select.lo sqlite3rbu.lo status.lo \
   183    183            table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
   184    184            update.lo util.lo vacuum.lo \
   185    185            vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
   186    186            vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
   187    187            utf.lo vtab.lo
   188    188   
   189    189   # Object files for the amalgamation.
................................................................................
  1024   1024   fts5.c: $(FTS5_SRC)
  1025   1025   	$(TCLSH_CMD) $(TOP)/ext/fts5/tool/mkfts5c.tcl
  1026   1026   	cp $(TOP)/ext/fts5/fts5.h .
  1027   1027   
  1028   1028   fts5.lo:	fts5.c $(HDR) $(EXTHDR)
  1029   1029   	$(LTCOMPILE) -DSQLITE_CORE -c fts5.c
  1030   1030   
         1031  +sqlite3rbu.lo:	$(TOP)/ext/rbu/sqlite3rbu.c $(HDR) $(EXTHDR)
         1032  +	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rbu/sqlite3rbu.c
         1033  +
  1031   1034   
  1032   1035   # Rules to build the 'testfixture' application.
  1033   1036   #
  1034   1037   # If using the amalgamation, use sqlite3.c directly to build the test
  1035   1038   # fixture.  Otherwise link against libsqlite3.la.  (This distinction is
  1036   1039   # necessary because the test fixture requires non-API symbols which are
  1037   1040   # hidden when the library is built via the amalgamation).
................................................................................
  1126   1129   	$(LTLINK) -I. -o $@ $(TOP)/tool/logest.c
  1127   1130   
  1128   1131   wordcount$(TEXE):	$(TOP)/test/wordcount.c sqlite3.c
  1129   1132   	$(LTLINK) -o $@ $(TOP)/test/wordcount.c sqlite3.c $(TLIBS)
  1130   1133   
  1131   1134   speedtest1$(TEXE):	$(TOP)/test/speedtest1.c sqlite3.lo
  1132   1135   	$(LTLINK) -o $@ $(TOP)/test/speedtest1.c sqlite3.lo $(TLIBS)
         1136  +
         1137  +rbu$(EXE): $(TOP)/ext/rbu/rbu.c $(TOP)/ext/rbu/sqlite3rbu.c sqlite3.lo 
         1138  +	$(LTLINK) -I. -o $@ $(TOP)/ext/rbu/rbu.c sqlite3.lo $(TLIBS)
         1139  +
         1140  +loadfts$(EXE): $(TOP)/tool/loadfts.c libsqlite3.la
         1141  +	$(LTLINK) $(TOP)/tool/loadfts.c libsqlite3.la -o $@ $(TLIBS)
  1133   1142   
  1134   1143   # This target will fail if the SQLite amalgamation contains any exported
  1135   1144   # symbols that do not begin with "sqlite3_". It is run as part of the
  1136   1145   # releasetest.tcl script.
  1137   1146   #
  1138   1147   checksymbols: sqlite3.lo
  1139   1148   	nm -g --defined-only sqlite3.o | grep -v " sqlite3_" ; test $$? -ne 0

Changes to Makefile.msc.

   835    835            func.lo global.lo hash.lo \
   836    836            icu.lo insert.lo journal.lo legacy.lo loadext.lo \
   837    837            main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
   838    838            memjournal.lo \
   839    839            mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
   840    840            notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
   841    841            pager.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
   842         -         random.lo resolve.lo rowset.lo rtree.lo select.lo status.lo \
          842  +         random.lo resolve.lo rowset.lo rtree.lo select.lo sqlite3rbu.lo status.lo \
   843    843            table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
   844    844            update.lo util.lo vacuum.lo \
   845    845            vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
   846    846            vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
   847    847            utf.lo vtab.lo
   848    848   
   849    849   # Object files for the amalgamation.
................................................................................
  1710   1710   
  1711   1711   fts5_ext.lo:	fts5.c $(HDR) $(EXTHDR)
  1712   1712   	$(LTCOMPILE) $(NO_WARN) -c fts5.c
  1713   1713   
  1714   1714   fts5.dll:	fts5_ext.lo
  1715   1715   	$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ fts5_ext.lo
  1716   1716   
         1717  +sqlite3rbu.lo:	$(TOP)/ext/rbu/sqlite3rbu.c $(HDR) $(EXTHDR)
         1718  +	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rbu/sqlite3rbu.c
         1719  +
  1717   1720   # Rules to build the 'testfixture' application.
  1718   1721   #
  1719   1722   # If using the amalgamation, use sqlite3.c directly to build the test
  1720   1723   # fixture.  Otherwise link against libsqlite3.lib.  (This distinction is
  1721   1724   # necessary because the test fixture requires non-API symbols which are
  1722   1725   # hidden when the library is built via the amalgamation).
  1723   1726   #
................................................................................
  1831   1834   wordcount.exe:	$(TOP)\test\wordcount.c $(SQLITE3C)
  1832   1835   	$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
  1833   1836   		$(TOP)\test\wordcount.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
  1834   1837   
  1835   1838   speedtest1.exe:	$(TOP)\test\speedtest1.c $(SQLITE3C)
  1836   1839   	$(LTLINK) $(NO_WARN) -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
  1837   1840   		$(TOP)\test\speedtest1.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
         1841  +
         1842  +rbu.exe: $(TOP)\ext\rbu\rbu.c $(TOP)\ext\rbu\sqlite3rbu.c $(SQLITE3C)
         1843  +	$(LTLINK) $(NO_WARN) -I. -DSQLITE_ENABLE_RBU -Fe$@ $(TOP)\ext\rbu\rbu.c $(SQLITE3C) \
         1844  +		$(LDFLAGS) $(LTLINKOPTS)
  1838   1845   
  1839   1846   clean:
  1840   1847   	del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL
  1841   1848   	del /Q *.bsc *.cod *.da *.bb *.bbg gmon.out 2>NUL
  1842   1849   	del /Q sqlite3.h opcodes.c opcodes.h 2>NUL
  1843   1850   	del /Q lemon.* lempar.c parse.* 2>NUL
  1844   1851   	del /Q mkkeywordhash.* keywordhash.h 2>NUL

Changes to ext/rbu/rbu.c.

    71     71     int nStep = 0;                  /* Maximum number of step() calls */
    72     72     int rc;
    73     73     sqlite3_int64 nProgress = 0;
    74     74   
    75     75     /* Process command line arguments. Following this block local variables 
    76     76     ** zTarget, zRbu and nStep are all set. */
    77     77     if( argc==5 ){
    78         -    int nArg1 = strlen(argv[1]);
           78  +    size_t nArg1 = strlen(argv[1]);
    79     79       if( nArg1>5 || nArg1<2 || memcmp("-step", argv[1], nArg1) ) usage(argv[0]);
    80     80       nStep = atoi(argv[2]);
    81     81     }else if( argc!=3 ){
    82     82       usage(argv[0]);
    83     83     }
    84     84     zTarget = argv[argc-2];
    85     85     zRbu = argv[argc-1];
................................................................................
    99     99     /* Let the user know what happened. */
   100    100     switch( rc ){
   101    101       case SQLITE_OK:
   102    102         sqlite3_snprintf(sizeof(zBuf), zBuf,
   103    103             "SQLITE_OK: rbu update incomplete (%lld operations so far)\n",
   104    104             nProgress
   105    105         );
   106         -      fprintf(stdout, zBuf);
          106  +      fprintf(stdout, "%s", zBuf);
   107    107         break;
   108    108   
   109    109       case SQLITE_DONE:
   110    110         sqlite3_snprintf(sizeof(zBuf), zBuf,
   111    111             "SQLITE_DONE: rbu update completed (%lld operations)\n",
   112    112             nProgress
   113    113         );
   114         -      fprintf(stdout, zBuf);
          114  +      fprintf(stdout, "%s", zBuf);
   115    115         break;
   116    116   
   117    117       default:
   118    118         fprintf(stderr, "error=%d: %s\n", rc, zErrmsg);
   119    119         break;
   120    120     }
   121    121   
   122    122     sqlite3_free(zErrmsg);
   123    123     return (rc==SQLITE_OK || rc==SQLITE_DONE) ? 0 : 1;
   124    124   }
   125         -

Changes to ext/rbu/sqlite3rbu.c.

   931    931   ** immediately without attempting the allocation or modifying the stored
   932    932   ** error code.
   933    933   */
   934    934   static void *rbuMalloc(sqlite3rbu *p, int nByte){
   935    935     void *pRet = 0;
   936    936     if( p->rc==SQLITE_OK ){
   937    937       assert( nByte>0 );
   938         -    pRet = sqlite3_malloc(nByte);
          938  +    pRet = sqlite3_malloc64(nByte);
   939    939       if( pRet==0 ){
   940    940         p->rc = SQLITE_NOMEM;
   941    941       }else{
   942    942         memset(pRet, 0, nByte);
   943    943       }
   944    944     }
   945    945     return pRet;
................................................................................
   977    977   ** if the allocation succeeds, (*pRc) is left unchanged.
   978    978   */
   979    979   static char *rbuStrndup(const char *zStr, int *pRc){
   980    980     char *zRet = 0;
   981    981   
   982    982     assert( *pRc==SQLITE_OK );
   983    983     if( zStr ){
   984         -    int nCopy = strlen(zStr) + 1;
   985         -    zRet = (char*)sqlite3_malloc(nCopy);
          984  +    size_t nCopy = strlen(zStr) + 1;
          985  +    zRet = (char*)sqlite3_malloc64(nCopy);
   986    986       if( zRet ){
   987    987         memcpy(zRet, zStr, nCopy);
   988    988       }else{
   989    989         *pRc = SQLITE_NOMEM;
   990    990       }
   991    991     }
   992    992   
................................................................................
  2326   2326       return SQLITE_INTERNAL;
  2327   2327     }
  2328   2328   
  2329   2329     pRbu->pgsz = iAmt;
  2330   2330     if( pRbu->nFrame==pRbu->nFrameAlloc ){
  2331   2331       int nNew = (pRbu->nFrameAlloc ? pRbu->nFrameAlloc : 64) * 2;
  2332   2332       RbuFrame *aNew;
  2333         -    aNew = (RbuFrame*)sqlite3_realloc(pRbu->aFrame, nNew * sizeof(RbuFrame));
         2333  +    aNew = (RbuFrame*)sqlite3_realloc64(pRbu->aFrame, nNew * sizeof(RbuFrame));
  2334   2334       if( aNew==0 ) return SQLITE_NOMEM;
  2335   2335       pRbu->aFrame = aNew;
  2336   2336       pRbu->nFrameAlloc = nNew;
  2337   2337     }
  2338   2338   
  2339   2339     iFrame = (u32)((iOff-32) / (i64)(iAmt+24)) + 1;
  2340   2340     if( pRbu->iMaxFrame<iFrame ) pRbu->iMaxFrame = iFrame;
................................................................................
  2391   2391     int nChar;
  2392   2392     LPWSTR zWideFilename;
  2393   2393   
  2394   2394     nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
  2395   2395     if( nChar==0 ){
  2396   2396       return 0;
  2397   2397     }
  2398         -  zWideFilename = sqlite3_malloc( nChar*sizeof(zWideFilename[0]) );
         2398  +  zWideFilename = sqlite3_malloc64( nChar*sizeof(zWideFilename[0]) );
  2399   2399     if( zWideFilename==0 ){
  2400   2400       return 0;
  2401   2401     }
  2402   2402     memset(zWideFilename, 0, nChar*sizeof(zWideFilename[0]));
  2403   2403     nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename,
  2404   2404                                   nChar);
  2405   2405     if( nChar==0 ){
................................................................................
  3025   3025   */
  3026   3026   sqlite3rbu *sqlite3rbu_open(
  3027   3027     const char *zTarget, 
  3028   3028     const char *zRbu,
  3029   3029     const char *zState
  3030   3030   ){
  3031   3031     sqlite3rbu *p;
  3032         -  int nTarget = strlen(zTarget);
  3033         -  int nRbu = strlen(zRbu);
  3034         -  int nState = zState ? strlen(zState) : 0;
         3032  +  size_t nTarget = strlen(zTarget);
         3033  +  size_t nRbu = strlen(zRbu);
         3034  +  size_t nState = zState ? strlen(zState) : 0;
         3035  +  size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1+ nState+1;
  3035   3036   
  3036         -  p = (sqlite3rbu*)sqlite3_malloc(sizeof(sqlite3rbu)+nTarget+1+nRbu+1+nState+1);
         3037  +  p = (sqlite3rbu*)sqlite3_malloc64(nByte);
  3037   3038     if( p ){
  3038   3039       RbuState *pState = 0;
  3039   3040   
  3040   3041       /* Create the custom VFS. */
  3041   3042       memset(p, 0, sizeof(sqlite3rbu));
  3042   3043       rbuCreateVfs(p);
  3043   3044   
................................................................................
  3166   3167   ** If the error code currently stored in the RBU handle is SQLITE_CONSTRAINT,
  3167   3168   ** then edit any error message string so as to remove all occurrences of
  3168   3169   ** the pattern "rbu_imp_[0-9]*".
  3169   3170   */
  3170   3171   static void rbuEditErrmsg(sqlite3rbu *p){
  3171   3172     if( p->rc==SQLITE_CONSTRAINT && p->zErrmsg ){
  3172   3173       int i;
  3173         -    int nErrmsg = strlen(p->zErrmsg);
         3174  +    size_t nErrmsg = strlen(p->zErrmsg);
  3174   3175       for(i=0; i<(nErrmsg-8); i++){
  3175   3176         if( memcmp(&p->zErrmsg[i], "rbu_imp_", 8)==0 ){
  3176   3177           int nDel = 8;
  3177   3178           while( p->zErrmsg[i+nDel]>='0' && p->zErrmsg[i+nDel]<='9' ) nDel++;
  3178   3179           memmove(&p->zErrmsg[i], &p->zErrmsg[i+nDel], nErrmsg + 1 - i - nDel);
  3179   3180           nErrmsg -= nDel;
  3180   3181         }
................................................................................
  3630   3631     /* If not in RBU_STAGE_OAL, allow this call to pass through. Or, if this
  3631   3632     ** rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space 
  3632   3633     ** instead of a file on disk.  */
  3633   3634     assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );
  3634   3635     if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){
  3635   3636       if( iRegion<=p->nShm ){
  3636   3637         int nByte = (iRegion+1) * sizeof(char*);
  3637         -      char **apNew = (char**)sqlite3_realloc(p->apShm, nByte);
         3638  +      char **apNew = (char**)sqlite3_realloc64(p->apShm, nByte);
  3638   3639         if( apNew==0 ){
  3639   3640           rc = SQLITE_NOMEM;
  3640   3641         }else{
  3641   3642           memset(&apNew[p->nShm], 0, sizeof(char*) * (1 + iRegion - p->nShm));
  3642   3643           p->apShm = apNew;
  3643   3644           p->nShm = iRegion+1;
  3644   3645         }
  3645   3646       }
  3646   3647   
  3647   3648       if( rc==SQLITE_OK && p->apShm[iRegion]==0 ){
  3648         -      char *pNew = (char*)sqlite3_malloc(szRegion);
         3649  +      char *pNew = (char*)sqlite3_malloc64(szRegion);
  3649   3650         if( pNew==0 ){
  3650   3651           rc = SQLITE_NOMEM;
  3651   3652         }else{
  3652   3653           memset(pNew, 0, szRegion);
  3653   3654           p->apShm[iRegion] = pNew;
  3654   3655         }
  3655   3656       }
................................................................................
  3751   3752     if( zName ){
  3752   3753       if( flags & SQLITE_OPEN_MAIN_DB ){
  3753   3754         /* A main database has just been opened. The following block sets
  3754   3755         ** (pFd->zWal) to point to a buffer owned by SQLite that contains
  3755   3756         ** the name of the *-wal file this db connection will use. SQLite
  3756   3757         ** happens to pass a pointer to this buffer when using xAccess()
  3757   3758         ** or xOpen() to operate on the *-wal file.  */
  3758         -      int n = strlen(zName);
         3759  +      int n = (int)strlen(zName);
  3759   3760         const char *z = &zName[n];
  3760   3761         if( flags & SQLITE_OPEN_URI ){
  3761   3762           int odd = 0;
  3762   3763           while( 1 ){
  3763   3764             if( z[0]==0 ){
  3764   3765               odd = 1 - odd;
  3765   3766               if( odd && z[1]==0 ) break;
................................................................................
  3777   3778         rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName);
  3778   3779         if( pDb ){
  3779   3780           if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
  3780   3781             /* This call is to open a *-wal file. Intead, open the *-oal. This
  3781   3782             ** code ensures that the string passed to xOpen() is terminated by a
  3782   3783             ** pair of '\0' bytes in case the VFS attempts to extract a URI 
  3783   3784             ** parameter from it.  */
  3784         -          int nCopy = strlen(zName);
  3785         -          char *zCopy = sqlite3_malloc(nCopy+2);
         3785  +          size_t nCopy = strlen(zName);
         3786  +          char *zCopy = sqlite3_malloc64(nCopy+2);
  3786   3787             if( zCopy ){
  3787   3788               memcpy(zCopy, zName, nCopy);
  3788   3789               zCopy[nCopy-3] = 'o';
  3789   3790               zCopy[nCopy] = '\0';
  3790   3791               zCopy[nCopy+1] = '\0';
  3791   3792               zOpen = (const char*)(pFd->zDel = zCopy);
  3792   3793             }else{
................................................................................
  4007   4008       rbuVfsCurrentTime,            /* xCurrentTime */
  4008   4009       rbuVfsGetLastError,           /* xGetLastError */
  4009   4010       0,                            /* xCurrentTimeInt64 (version 2) */
  4010   4011       0, 0, 0                       /* Unimplemented version 3 methods */
  4011   4012     };
  4012   4013   
  4013   4014     rbu_vfs *pNew = 0;              /* Newly allocated VFS */
  4014         -  int nName;
  4015   4015     int rc = SQLITE_OK;
         4016  +  size_t nName;
         4017  +  size_t nByte;
  4016   4018   
  4017         -  int nByte;
  4018   4019     nName = strlen(zName);
  4019   4020     nByte = sizeof(rbu_vfs) + nName + 1;
  4020         -  pNew = (rbu_vfs*)sqlite3_malloc(nByte);
         4021  +  pNew = (rbu_vfs*)sqlite3_malloc64(nByte);
  4021   4022     if( pNew==0 ){
  4022   4023       rc = SQLITE_NOMEM;
  4023   4024     }else{
  4024   4025       sqlite3_vfs *pParent;           /* Parent VFS */
  4025   4026       memset(pNew, 0, nByte);
  4026   4027       pParent = sqlite3_vfs_find(zParent);
  4027   4028       if( pParent==0 ){