]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
All multiplexor chunk sizes up to 4GiB. Disable the multiplexor if the
authordrh <drh@noemail.net>
Thu, 21 Jul 2011 20:59:58 +0000 (20:59 +0000)
committerdrh <drh@noemail.net>
Thu, 21 Jul 2011 20:59:58 +0000 (20:59 +0000)
chunk size is set to 0.

FossilOrigin-Name: 83191ad6f31536b0c1929938e1fbeb4cf6121ab0

manifest
manifest.uuid
src/test_multiplex.c
test/multiplex.test

index b768ecaf189eb93f4c02c4149bdbbb7c0a0c2c89..5bca43402e6d00175d144346b3bc1f7ca29c5d4c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C For\san\sexisting\smultiplexed\sdatabase,\stry\sto\sset\sthe\schunk\ssize\sautomatically\nbased\son\sthe\ssizes\sof\sthe\spreexisting\spieces.
-D 2011-07-20T17:59:38.568
+C All\smultiplexor\schunk\ssizes\sup\sto\s4GiB.\s\sDisable\sthe\smultiplexor\sif\sthe\nchunk\ssize\sis\sset\sto\s0.
+D 2011-07-21T20:59:58.248
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -213,7 +213,7 @@ F src/test_intarray.h 489edb9068bb926583445cb02589344961054207
 F src/test_journal.c 03313c693cca72959dcaaf79f8d76f21c01e19ff
 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
 F src/test_malloc.c 7ca7be34e0e09ef0ed6619544552ed95732e41f6
-F src/test_multiplex.c 7f5b2ec63ff514f12e95ffbe134fca87eaac7e96
+F src/test_multiplex.c 991a60733dbde8c529043d466c5c44d180762561
 F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d
 F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e
 F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec
@@ -595,7 +595,7 @@ F test/misc5.test 9f9338f8211c7f5d1cbe16331fa65d019501aa50
 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
 F test/misc7.test 29032efcd3d826fbd409e2a7af873e7939f4a4e3
 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33
-F test/multiplex.test 2256e90e8780de6eeafc07d4084427c3a97d3bcb
+F test/multiplex.test b45367b1dac7dfa4c5b8ff0f3844260804a0034d
 F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41
 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
 F test/nan.test dc212a22b36109fd1ae37154292444ef249c5ec2
@@ -952,7 +952,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262
-P 29866f9598502a007816410fade34f1d0952dea0
-R f7447480ebd05c67794755dbb19b5608
+P 427a9a5120a68bfa12fec97cfd02eb9b28b3fa6b
+R 046ebc91a200dc382cece52b5754a0c1
 U drh
-Z ce5790e6bda5ced4f7371ad338df0dcd
+Z 032caca1acf96a44c6601a79dc41d32f
index 372fbaa1880071975e43138e0cc78e1e5b88680a..3b6b9433273acde08ee208637098c2b1e70034aa 100644 (file)
@@ -1 +1 @@
-427a9a5120a68bfa12fec97cfd02eb9b28b3fa6b
\ No newline at end of file
+83191ad6f31536b0c1929938e1fbeb4cf6121ab0
\ No newline at end of file
index c5725e07a21e59326f24b9058957d7044cabe30b..732df82cd708ad7339cf2cf289352c084c5fc616 100644 (file)
@@ -134,7 +134,7 @@ struct multiplexGroup {
   char *zName;                     /* Base filename of this group */
   int nName;                       /* Length of base filename */
   int flags;                       /* Flags used for original opening */
-  int nChunkSize;                  /* Chunk size used for this group */
+  unsigned int szChunk;            /* Chunk size used for this group */
   int bEnabled;                    /* TRUE to use Multiplex VFS for this file */
   multiplexGroup *pNext, *pPrev;   /* Doubly linked list of all group objects */
 };
@@ -494,18 +494,27 @@ static int multiplexOpen(
   }
 
   if( rc==SQLITE_OK ){
-    const char *zChunkSize;
     /* assign pointers to extra space allocated */
     char *p = (char *)&pGroup[1];
     pMultiplexOpen->pGroup = pGroup;
     memset(pGroup, 0, sz);
     pGroup->bEnabled = -1;
-    pGroup->nChunkSize = SQLITE_MULTIPLEX_CHUNK_SIZE;
+    pGroup->szChunk = SQLITE_MULTIPLEX_CHUNK_SIZE;
     if( flags & SQLITE_OPEN_URI ){
+      const char *zChunkSize;
       zChunkSize = sqlite3_uri_parameter(zName, "chunksize");
       if( zChunkSize ){
-        int n = atoi(zChunkSize);
-        if( n>0 ) pGroup->nChunkSize = (n+0xffff)&~0xffff;
+        unsigned int n = 0;
+        int i;
+        for(i=0; zChunkSize[i]>='0' && zChunkSize[i]<='9'; i++){
+          n = n*10 + zChunkSize[i] - '0';
+        }
+        if( n>0 ){
+          pGroup->szChunk = (n+0xffff)&~0xffff;
+        }else{
+          /* A zero or negative chunksize disabled the multiplexor */
+          pGroup->bEnabled = 0;
+        }
       }
     }
     pGroup->zName = p;
@@ -535,9 +544,9 @@ static int multiplexOpen(
         rc3 = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[1].z,
             SQLITE_ACCESS_EXISTS, &exists);
         if( rc3==SQLITE_OK && exists && sz==(sz&0xffff0000) && sz>0
-            && sz!=pGroup->nChunkSize ){
-          pGroup->nChunkSize = sz;
-        }else if( rc3==SQLITE_OK && !exists && sz>pGroup->nChunkSize ){
+            && sz!=pGroup->szChunk ){
+          pGroup->szChunk = sz;
+        }else if( rc3==SQLITE_OK && !exists && sz>pGroup->szChunk ){
           pGroup->bEnabled = 0;
         }
       }
@@ -656,15 +665,14 @@ static int multiplexRead(
     }
   }else{
     while( iAmt > 0 ){
-      int i = (int)(iOfst / pGroup->nChunkSize);
+      int i = (int)(iOfst / pGroup->szChunk);
       sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL);
       if( pSubOpen ){
-        int extra = ((int)(iOfst % pGroup->nChunkSize) + iAmt) -
-                                                        pGroup->nChunkSize;
+        int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) - pGroup->szChunk;
         if( extra<0 ) extra = 0;
         iAmt -= extra;
         rc = pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt,
-                                       iOfst % pGroup->nChunkSize);
+                                       iOfst % pGroup->szChunk);
         if( rc!=SQLITE_OK ) break;
         pBuf = (char *)pBuf + iAmt;
         iOfst += iAmt;
@@ -702,15 +710,15 @@ static int multiplexWrite(
     }
   }else{
     while( iAmt > 0 ){
-      int i = (int)(iOfst / pGroup->nChunkSize);
+      int i = (int)(iOfst / pGroup->szChunk);
       sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL);
       if( pSubOpen ){
-        int extra = ((int)(iOfst % pGroup->nChunkSize) + iAmt) -
-                    pGroup->nChunkSize;
+        int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) -
+                    pGroup->szChunk;
         if( extra<0 ) extra = 0;
         iAmt -= extra;
         rc = pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt,
-                                        iOfst % pGroup->nChunkSize);
+                                        iOfst % pGroup->szChunk);
         if( rc!=SQLITE_OK ) break;
         pBuf = (char *)pBuf + iAmt;
         iOfst += iAmt;
@@ -747,12 +755,12 @@ static int multiplexTruncate(sqlite3_file *pConn, sqlite3_int64 size){
     sqlite3_file *pSubOpen;
     sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
     /* delete the chunks above the truncate limit */
-    for(i=(int)(size / pGroup->nChunkSize)+1; i<pGroup->nReal; i++){
+    for(i=(int)(size / pGroup->szChunk)+1; i<pGroup->nReal; i++){
       multiplexSubClose(pGroup, i, pOrigVfs);
     }
-    pSubOpen = multiplexSubOpen(pGroup, (int)(size/pGroup->nChunkSize), &rc2,0);
+    pSubOpen = multiplexSubOpen(pGroup, (int)(size/pGroup->szChunk), &rc2,0);
     if( pSubOpen ){
-      rc2 = pSubOpen->pMethods->xTruncate(pSubOpen, size % pGroup->nChunkSize);
+      rc2 = pSubOpen->pMethods->xTruncate(pSubOpen, size % pGroup->szChunk);
       if( rc2!=SQLITE_OK ) rc = rc2;
     }else{
       rc = SQLITE_IOERR_TRUNCATE;
@@ -821,7 +829,7 @@ static int multiplexFileSize(sqlite3_file *pConn, sqlite3_int64 *pSize){
         if( rc2!=SQLITE_OK ){
           rc = rc2;
         }else{
-          if( sz>pGroup->nChunkSize ){
+          if( sz>pGroup->szChunk ){
             rc = SQLITE_IOERR_FSTAT;
           }
           *pSize += sz;
@@ -891,14 +899,14 @@ static int multiplexFileControl(sqlite3_file *pConn, int op, void *pArg){
       break;
     case MULTIPLEX_CTRL_SET_CHUNK_SIZE:
       if( pArg ) {
-        int nChunkSize = *(int *)pArg;
-        if( nChunkSize<1 ){
+        unsigned int szChunk = *(unsigned*)pArg;
+        if( szChunk<1 ){
           rc = SQLITE_MISUSE;
         }else{
           /* Round up to nearest multiple of MAX_PAGE_SIZE. */
-          nChunkSize = (nChunkSize + (MAX_PAGE_SIZE-1));
-          nChunkSize &= ~(MAX_PAGE_SIZE-1);
-          pGroup->nChunkSize = nChunkSize;
+          szChunk = (szChunk + (MAX_PAGE_SIZE-1));
+          szChunk &= ~(MAX_PAGE_SIZE-1);
+          pGroup->szChunk = szChunk;
           rc = SQLITE_OK;
         }
       }
@@ -1194,7 +1202,7 @@ static int test_multiplex_dump(
           Tcl_NewIntObj(nChunks));
 
     Tcl_ListObjAppendElement(interp, pGroupTerm,
-          Tcl_NewIntObj(pGroup->nChunkSize));
+          Tcl_NewIntObj(pGroup->szChunk));
     Tcl_ListObjAppendElement(interp, pGroupTerm,
           Tcl_NewIntObj(pGroup->nReal));
 
index 93d4aafc1695dddb4fe5265bb741db4f2d4e9273..28ce1c77e7c987dd7b51ab8b341e905472976700 100644 (file)
@@ -80,7 +80,6 @@ do_test multiplex-1.9.1  { sqlite3_multiplex_initialize "" 1 }     {SQLITE_OK}
 do_test multiplex-1.9.2  { sqlite3 db test.db }                    {}
 do_test multiplex-1.9.3  { multiplex_set db main 32768 16 }        {SQLITE_OK}
 do_test multiplex-1.9.4  { multiplex_set db main 32768 -1 }        {SQLITE_OK}
-do_test multiplex-1.9.5  { multiplex_set db main -1 16 }           {SQLITE_MISUSE}
 do_test multiplex-1.9.6  { multiplex_set db main 31 16 }           {SQLITE_OK}
 do_test multiplex-1.9.7  { multiplex_set db main 32768 100 }       {SQLITE_OK}
 do_test multiplex-1.9.8  { multiplex_set db main 1073741824 1 }    {SQLITE_OK}
@@ -91,7 +90,6 @@ do_test multiplex-1.10.1  { sqlite3_multiplex_initialize "" 1 }
 do_test multiplex-1.10.2  { sqlite3 db test.db }                                                 {}
 do_test multiplex-1.10.3  { lindex [ catchsql { SELECT multiplex_control(2, 32768); } ] 0 }      {0}
 do_test multiplex-1.10.4  { lindex [ catchsql { SELECT multiplex_control(3, -1); } ] 0 }         {0}
-do_test multiplex-1.10.5  { lindex [ catchsql { SELECT multiplex_control(2, -1); } ] 0 }         {1}
 do_test multiplex-1.10.6  { lindex [ catchsql { SELECT multiplex_control(2, 31); } ] 0 }         {0}
 do_test multiplex-1.10.7  { lindex [ catchsql { SELECT multiplex_control(3, 100); } ] 0 }        {0}
 do_test multiplex-1.10.8  { lindex [ catchsql { SELECT multiplex_control(2, 1073741824); } ] 0 } {0}