]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enable/disable support.
authorshaneh <shaneh@noemail.net>
Thu, 31 Mar 2011 15:11:53 +0000 (15:11 +0000)
committershaneh <shaneh@noemail.net>
Thu, 31 Mar 2011 15:11:53 +0000 (15:11 +0000)
FossilOrigin-Name: b3c6d9aa9e2124a2f2a1a5f9dbbd7db3b1d01a31

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

index d4d42b146b9bf440c986c316137ed8d88b797d6f..43d10d38457f239c261763ec6bd2ceb5085e6a51 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Tests\sand\sbug\sfixes\sfor\sSELECT\smultiplex_control(op,\sval);\nAdd\stests\sand\sfixes\sfor\sSELECT\smultiplex_control(op,\sval);
-D 2011-03-31T13:14:12.476
+C Enable/disable\ssupport.
+D 2011-03-31T15:11:53.959
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -209,7 +209,7 @@ F src/test_intarray.h 489edb9068bb926583445cb02589344961054207
 F src/test_journal.c 785edd54f963aefb3c1628124170a56697c68c70
 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
 F src/test_malloc.c fd6188b1501c0010fb4241ddc9f0d5ac402c688d
-F src/test_multiplex.c 07dff88008c801899680eec3b9b0ea30be9fba62
+F src/test_multiplex.c c0d9450b63b0f785795e4873ce90002414921a61
 F src/test_multiplex.h bf7b2d303688c32cdd1cee3ffdc377f13391e311
 F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e
 F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec
@@ -576,7 +576,7 @@ F test/misc5.test 45b2e3ed5f79af2b4f38ae362eaf4c49674575bd
 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
 F test/misc7.test 29032efcd3d826fbd409e2a7af873e7939f4a4e3
 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33
-F test/multiplex.test 74009eeb9b1186855a56ad522f5daf9bcf6ee134
+F test/multiplex.test 5373b2c3b0f3e262e746652d8f93b6f6297b15ba
 F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41
 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
 F test/nan.test a44e04df1486fcfb02d32468cbcd3c8e1e433723
@@ -914,7 +914,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 36e364a3fe7d3a9a521189ff0262611a492c21dc
-R 139c8e5f53872b2a8fa7c9d64e54233c
+P fee9734c193a8bec9599e02e16938179e642bf5e
+R 9ef3873d6c48b9ead5e6ba118b2bc91f
 U shaneh
-Z 22cc15d919103b40af9da38b0122d8bd
+Z 53dc1c2b6709916c1194488b48f81a5e
index eb27bb55e165892cb967e76b95ac8508767326db..1ae76db767a5f08dd31101091a178b7d45c80808 100644 (file)
@@ -1 +1 @@
-fee9734c193a8bec9599e02e16938179e642bf5e
\ No newline at end of file
+b3c6d9aa9e2124a2f2a1a5f9dbbd7db3b1d01a31
\ No newline at end of file
index 214cddcaf1f7873a8551d4e57d840ba2daf9ad20..a49825717eb31c9334b35291d1640202a1045658 100644 (file)
 
 /* This is the limit on the chunk size.  It may be changed by calling
 ** the xFileControl() interface.  It will be rounded up to a 
-** multiple of SQLITE_MAX_PAGE_SIZE.
+** multiple of SQLITE_MAX_PAGE_SIZE.  We default it here to 1GB.
 */
-#define SQLITE_MULTIPLEX_CHUNK_SIZE (SQLITE_MAX_PAGE_SIZE*32)
+#define SQLITE_MULTIPLEX_CHUNK_SIZE (SQLITE_MAX_PAGE_SIZE*16384)
+
 /* Default limit on number of chunks.  Care should be taken
 ** so that values for chunks numbers fit in the SQLITE_MULTIPLEX_EXT_FMT
 ** format specifier. It may be changed by calling
@@ -305,6 +306,7 @@ static int multiplexOpen(
     char *p = (char *)&pGroup[1];
     pMultiplexOpen->pGroup = pGroup;
     memset(pGroup, 0, sz);
+    pGroup->bEnabled = -1;
     pGroup->nChunkSize = SQLITE_MULTIPLEX_CHUNK_SIZE;
     pGroup->nMaxChunks = SQLITE_MULTIPLEX_MAX_CHUNKS;
     pGroup->pReal = (sqlite3_file **)p;
@@ -323,6 +325,14 @@ static int multiplexOpen(
     pGroup->flags = flags;
     pSubOpen = multiplexSubOpen(pMultiplexOpen, 0, &rc, pOutFlags);
     if( pSubOpen ){
+      /* if this file is already larger than chunk size, disable 
+      ** the multiplex feature.
+      */
+      sqlite3_int64 sz;
+      int rc2 = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
+      if( (rc2==SQLITE_OK) && (sz>pGroup->nChunkSize) ){
+        pGroup->bEnabled = 0;
+      }
       if( pSubOpen->pMethods->iVersion==1 ){
         pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV1;
       }else{
@@ -465,21 +475,26 @@ static int multiplexRead(
   multiplexGroup *pGroup = p->pGroup;
   int rc = SQLITE_OK;
   multiplexEnter();
-  while( iAmt > 0 ){
-    int i = (int)(iOfst / pGroup->nChunkSize);
-    sqlite3_file *pSubOpen = multiplexSubOpen(p, i, &rc, NULL);
-    if( pSubOpen ){
-      int extra = ((int)(iOfst % pGroup->nChunkSize) + iAmt) - pGroup->nChunkSize;
-      if( extra<0 ) extra = 0;
-      iAmt -= extra;
-      rc = pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt, iOfst % pGroup->nChunkSize);
-      if( rc!=SQLITE_OK ) break;
-      pBuf = (char *)pBuf + iAmt;
-      iOfst += iAmt;
-      iAmt = extra;
-    }else{
-      rc = SQLITE_IOERR_READ;
-      break;
+  if( !pGroup->bEnabled ){
+    sqlite3_file *pSubOpen = multiplexSubOpen(p, 0, &rc, NULL);
+    rc = ( !pSubOpen ) ? SQLITE_IOERR_READ : pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt, iOfst);
+  }else{
+    while( iAmt > 0 ){
+      int i = (int)(iOfst / pGroup->nChunkSize);
+      sqlite3_file *pSubOpen = multiplexSubOpen(p, i, &rc, NULL);
+      if( pSubOpen ){
+        int extra = ((int)(iOfst % pGroup->nChunkSize) + iAmt) - pGroup->nChunkSize;
+        if( extra<0 ) extra = 0;
+        iAmt -= extra;
+        rc = pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt, iOfst % pGroup->nChunkSize);
+        if( rc!=SQLITE_OK ) break;
+        pBuf = (char *)pBuf + iAmt;
+        iOfst += iAmt;
+        iAmt = extra;
+      }else{
+        rc = SQLITE_IOERR_READ;
+        break;
+      }
     }
   }
   multiplexLeave();
@@ -500,21 +515,26 @@ static int multiplexWrite(
   multiplexGroup *pGroup = p->pGroup;
   int rc = SQLITE_OK;
   multiplexEnter();
-  while( iAmt > 0 ){
-    int i = (int)(iOfst / pGroup->nChunkSize);
-    sqlite3_file *pSubOpen = multiplexSubOpen(p, i, &rc, NULL);
-    if( pSubOpen ){
-      int extra = ((int)(iOfst % pGroup->nChunkSize) + iAmt) - pGroup->nChunkSize;
-      if( extra<0 ) extra = 0;
-      iAmt -= extra;
-      rc = pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt, iOfst % pGroup->nChunkSize);
-      if( rc!=SQLITE_OK ) break;
-      pBuf = (char *)pBuf + iAmt;
-      iOfst += iAmt;
-      iAmt = extra;
-    }else{
-      rc = SQLITE_IOERR_WRITE;
-      break;
+  if( !pGroup->bEnabled ){
+    sqlite3_file *pSubOpen = multiplexSubOpen(p, 0, &rc, NULL);
+    rc = ( !pSubOpen ) ? SQLITE_IOERR_WRITE : pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt, iOfst);
+  }else{
+    while( iAmt > 0 ){
+      int i = (int)(iOfst / pGroup->nChunkSize);
+      sqlite3_file *pSubOpen = multiplexSubOpen(p, i, &rc, NULL);
+      if( pSubOpen ){
+        int extra = ((int)(iOfst % pGroup->nChunkSize) + iAmt) - pGroup->nChunkSize;
+        if( extra<0 ) extra = 0;
+        iAmt -= extra;
+        rc = pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt, iOfst % pGroup->nChunkSize);
+        if( rc!=SQLITE_OK ) break;
+        pBuf = (char *)pBuf + iAmt;
+        iOfst += iAmt;
+        iAmt = extra;
+      }else{
+        rc = SQLITE_IOERR_WRITE;
+        break;
+      }
     }
   }
   multiplexLeave();
@@ -529,35 +549,40 @@ static int multiplexTruncate(sqlite3_file *pConn, sqlite3_int64 size){
   multiplexConn *p = (multiplexConn*)pConn;
   multiplexGroup *pGroup = p->pGroup;
   int rc = SQLITE_OK;
-  int rc2;
-  int i;
-  sqlite3_file *pSubOpen;
-  sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
   multiplexEnter();
-  memcpy(gMultiplex.zName, pGroup->zName, pGroup->nName+1);
-  /* delete the chunks above the truncate limit */
-  for(i=(int)(size / pGroup->nChunkSize)+1; i<pGroup->nMaxChunks; i++){
-    /* close any open chunks before deleting them */
-    if( pGroup->bOpen[i] ){
-      pSubOpen = pGroup->pReal[i];
-      rc2 = pSubOpen->pMethods->xClose(pSubOpen);
-      if( rc2!=SQLITE_OK ) rc = SQLITE_IOERR_TRUNCATE;
-      pGroup->bOpen[i] = 0;
-    }
+  if( !pGroup->bEnabled ){
+    sqlite3_file *pSubOpen = multiplexSubOpen(p, 0, &rc, NULL);
+    rc = ( !pSubOpen ) ? SQLITE_IOERR_TRUNCATE : pSubOpen->pMethods->xTruncate(pSubOpen, size);
+  }else{
+    int rc2;
+    int i;
+    sqlite3_file *pSubOpen;
+    sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
+    memcpy(gMultiplex.zName, pGroup->zName, pGroup->nName+1);
+    /* delete the chunks above the truncate limit */
+    for(i=(int)(size / pGroup->nChunkSize)+1; i<pGroup->nMaxChunks; i++){
+      /* close any open chunks before deleting them */
+      if( pGroup->bOpen[i] ){
+        pSubOpen = pGroup->pReal[i];
+        rc2 = pSubOpen->pMethods->xClose(pSubOpen);
+        if( rc2!=SQLITE_OK ) rc = SQLITE_IOERR_TRUNCATE;
+        pGroup->bOpen[i] = 0;
+      }
 #ifdef SQLITE_MULTIPLEX_EXT_OVWR
-    sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName-SQLITE_MULTIPLEX_EXT_SZ, SQLITE_MULTIPLEX_EXT_FMT, i);
+      sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName-SQLITE_MULTIPLEX_EXT_SZ, SQLITE_MULTIPLEX_EXT_FMT, i);
 #else
-    sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName, SQLITE_MULTIPLEX_EXT_FMT, i);
+      sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName, SQLITE_MULTIPLEX_EXT_FMT, i);
 #endif
-    rc2 = pOrigVfs->xDelete(pOrigVfs, gMultiplex.zName, 0);
-    if( rc2!=SQLITE_OK ) rc = SQLITE_IOERR_TRUNCATE;
-  }
-  pSubOpen = multiplexSubOpen(p, (int)(size / pGroup->nChunkSize), &rc2, NULL);
-  if( pSubOpen ){
-    rc2 = pSubOpen->pMethods->xTruncate(pSubOpen, size % pGroup->nChunkSize);
-    if( rc2!=SQLITE_OK ) rc = rc2;
-  }else{
-    rc = SQLITE_IOERR_TRUNCATE;
+      rc2 = pOrigVfs->xDelete(pOrigVfs, gMultiplex.zName, 0);
+      if( rc2!=SQLITE_OK ) rc = SQLITE_IOERR_TRUNCATE;
+    }
+    pSubOpen = multiplexSubOpen(p, (int)(size / pGroup->nChunkSize), &rc2, NULL);
+    if( pSubOpen ){
+      rc2 = pSubOpen->pMethods->xTruncate(pSubOpen, size % pGroup->nChunkSize);
+      if( rc2!=SQLITE_OK ) rc = rc2;
+    }else{
+      rc = SQLITE_IOERR_TRUNCATE;
+    }
   }
   multiplexLeave();
   return rc;
@@ -593,46 +618,51 @@ static int multiplexFileSize(sqlite3_file *pConn, sqlite3_int64 *pSize){
   int rc2;
   int i;
   multiplexEnter();
-  *pSize = 0;
-  for(i=0; i<pGroup->nMaxChunks; i++){
-    sqlite3_file *pSubOpen = NULL;
-    /* if not opened already, check to see if the chunk exists */
-    if( pGroup->bOpen[i] ){
-      pSubOpen = pGroup->pReal[i];
-    }else{
-      sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
-      int exists = 0;
-      memcpy(gMultiplex.zName, pGroup->zName, pGroup->nName+1);
-      if( i ){
+  if( !pGroup->bEnabled ){
+    sqlite3_file *pSubOpen = multiplexSubOpen(p, 0, &rc, NULL);
+    rc = ( !pSubOpen ) ? SQLITE_IOERR_FSTAT : pSubOpen->pMethods->xFileSize(pSubOpen, pSize);
+  }else{
+    *pSize = 0;
+    for(i=0; i<pGroup->nMaxChunks; i++){
+      sqlite3_file *pSubOpen = NULL;
+      /* if not opened already, check to see if the chunk exists */
+      if( pGroup->bOpen[i] ){
+        pSubOpen = pGroup->pReal[i];
+      }else{
+        sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
+        int exists = 0;
+        memcpy(gMultiplex.zName, pGroup->zName, pGroup->nName+1);
+        if( i ){
 #ifdef SQLITE_MULTIPLEX_EXT_OVWR
-        sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName-SQLITE_MULTIPLEX_EXT_SZ, SQLITE_MULTIPLEX_EXT_FMT, i);
+          sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName-SQLITE_MULTIPLEX_EXT_SZ, SQLITE_MULTIPLEX_EXT_FMT, i);
 #else
-        sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName, SQLITE_MULTIPLEX_EXT_FMT, i);
+          sqlite3_snprintf(SQLITE_MULTIPLEX_EXT_SZ+1, gMultiplex.zName+pGroup->nName, SQLITE_MULTIPLEX_EXT_FMT, i);
 #endif
+        }
+        rc2 = pOrigVfs->xAccess(pOrigVfs, gMultiplex.zName, SQLITE_ACCESS_EXISTS, &exists);
+        if( rc2==SQLITE_OK && exists){
+          /* if it exists, open it */
+          pSubOpen = multiplexSubOpen(p, i, &rc, NULL);
+        }else{
+          /* stop at first "gap" */
+          break;
+        }
       }
-      rc2 = pOrigVfs->xAccess(pOrigVfs, gMultiplex.zName, SQLITE_ACCESS_EXISTS, &exists);
-      if( rc2==SQLITE_OK && exists){
-        /* if it exists, open it */
-        pSubOpen = multiplexSubOpen(p, i, &rc, NULL);
+      if( pSubOpen ){
+        sqlite3_int64 sz;
+        rc2 = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
+        if( rc2!=SQLITE_OK ){
+          rc = rc2;
+        }else{
+          if( sz>pGroup->nChunkSize ){
+            rc = SQLITE_IOERR_FSTAT;
+          }
+          *pSize += sz;
+        }
       }else{
-        /* stop at first "gap" */
         break;
       }
     }
-    if( pSubOpen ){
-      sqlite3_int64 sz;
-      rc2 = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
-      if( rc2!=SQLITE_OK ){
-        rc = rc2;
-      }else{
-        if( sz>pGroup->nChunkSize ){
-          rc = SQLITE_IOERR_FSTAT;
-        }
-        *pSize += sz;
-      }
-    }else{
-      break;
-    }
   }
   multiplexLeave();
   return rc;
@@ -674,7 +704,8 @@ static int multiplexCheckReservedLock(sqlite3_file *pConn, int *pResOut){
   return SQLITE_IOERR_CHECKRESERVEDLOCK;
 }
 
-/* Pass xFileControl requests through to the original VFS unchanged.
+/* Pass xFileControl requests through to the original VFS unchanged,
+** except for any MULTIPLEX_CTRL_* requests here.
 */
 static int multiplexFileControl(sqlite3_file *pConn, int op, void *pArg){
   multiplexConn *p = (multiplexConn*)pConn;
@@ -1046,8 +1077,8 @@ static int test_multiplex_control(
     { 0, 0, 0 }
   };
 
-  if( objc!=4 && objc!=5 ){
-    Tcl_WrongNumArgs(interp, 1, objv, "HANDLE DBNAME SUB-COMMAND ?INT-VALUE?");
+  if( objc!=5 ){
+    Tcl_WrongNumArgs(interp, 1, objv, "HANDLE DBNAME SUB-COMMAND INT-VALUE");
     return TCL_ERROR;
   }
 
@@ -1066,10 +1097,6 @@ static int test_multiplex_control(
 
   switch( aSub[idx].argtype ){
     case 1:
-      if( objc!=5 ){
-        Tcl_WrongNumArgs(interp, 4, objv, "INT-VALUE");
-        return TCL_ERROR;
-      }
       if( Tcl_GetIntFromObj(interp, objv[4], &iValue) ){
         return TCL_ERROR;
       }
index 2d6642e243589edd85da308eed742166d985ac0d..c76cee71a049d74ae1847b679807344272c0ca68 100644 (file)
@@ -14,7 +14,7 @@ set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 source $testdir/malloc_common.tcl
 
-set g_chunk_size 2147483648
+set g_chunk_size [ expr ($::SQLITE_MAX_PAGE_SIZE*16384) ]
 set g_max_chunks 32
 
 # This handles appending the chunk number
@@ -74,25 +74,44 @@ do_test multiplex-1.6 { sqlite3_multiplex_shutdown }               {SQLITE_OK}
 do_test multiplex-1.7 { sqlite3_multiplex_initialize "" 1 }        {SQLITE_OK}
 do_test multiplex-1.8 { sqlite3_multiplex_shutdown }               {SQLITE_OK}
 
-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_MISUSE}
-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_MISUSE}
-do_test multiplex-1.9.8 { db close }                              {}
-do_test multiplex-1.9.9 { sqlite3_multiplex_shutdown }            {SQLITE_OK}
-
-do_test multiplex-1.10.1 { sqlite3_multiplex_initialize "" 1 }                {SQLITE_OK}
-do_test multiplex-1.10.2 { sqlite3 db test.db }                               {}
-do_test multiplex-1.10.3 { execsql { SELECT multiplex_control(2, 32768); } }  {SQLITE_OK}
-do_test multiplex-1.10.4 { execsql { SELECT multiplex_control(3, -1); } }     {SQLITE_MISUSE}
-do_test multiplex-1.10.5 { execsql { SELECT multiplex_control(2, -1); } }     {SQLITE_MISUSE}
-do_test multiplex-1.10.6 { execsql { SELECT multiplex_control(2, 31); } }     {SQLITE_OK}
-do_test multiplex-1.10.7 { execsql { SELECT multiplex_control(3, 100); } }    {SQLITE_MISUSE}
-do_test multiplex-1.10.8 { db close }                                         {}
-do_test multiplex-1.10.9 { sqlite3_multiplex_shutdown }                       {SQLITE_OK}
+
+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_MISUSE}
+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_MISUSE}
+do_test multiplex-1.9.8  { multiplex_set db main 1073741824 1 }    {SQLITE_OK}
+do_test multiplex-1.9.9  { db close }                              {}
+do_test multiplex-1.9.10 { sqlite3_multiplex_shutdown }            {SQLITE_OK}
+
+do_test multiplex-1.10.1  { sqlite3_multiplex_initialize "" 1 }                     {SQLITE_OK}
+do_test multiplex-1.10.2  { sqlite3 db test.db }                                    {}
+do_test multiplex-1.10.3  { execsql { SELECT multiplex_control(2, 32768); } }       {SQLITE_OK}
+do_test multiplex-1.10.4  { execsql { SELECT multiplex_control(3, -1); } }          {SQLITE_MISUSE}
+do_test multiplex-1.10.5  { execsql { SELECT multiplex_control(2, -1); } }          {SQLITE_MISUSE}
+do_test multiplex-1.10.6  { execsql { SELECT multiplex_control(2, 31); } }          {SQLITE_OK}
+do_test multiplex-1.10.7  { execsql { SELECT multiplex_control(3, 100); } }         {SQLITE_MISUSE}
+do_test multiplex-1.10.8  { execsql { SELECT multiplex_control(2, 1073741824); } }  {SQLITE_OK}
+do_test multiplex-1.10.9  { db close }                                              {}
+do_test multiplex-1.10.10 { sqlite3_multiplex_shutdown }                            {SQLITE_OK}
+
+do_test multiplex-1.11.1  { sqlite3_multiplex_initialize "" 1 }                 {SQLITE_OK}
+do_test multiplex-1.11.2  { sqlite3 db test.db }                                {}
+do_test multiplex-1.11.3  { sqlite3_multiplex_control db main enable 0  }       {SQLITE_OK}
+do_test multiplex-1.11.4  { sqlite3_multiplex_control db main enable 1  }       {SQLITE_OK}
+do_test multiplex-1.11.5  { sqlite3_multiplex_control db main enable -1 }       {SQLITE_OK}
+do_test multiplex-1.11.6  { db close }                                          {}
+do_test multiplex-1.11.7  { sqlite3_multiplex_shutdown }                        {SQLITE_OK}
+
+do_test multiplex-1.12.1  { sqlite3_multiplex_initialize "" 1 }                 {SQLITE_OK}
+do_test multiplex-1.12.2  { sqlite3 db test.db }                                {}
+do_test multiplex-1.12.3  { execsql { SELECT multiplex_control(1, 0); } }       {SQLITE_OK}
+do_test multiplex-1.12.4  { execsql { SELECT multiplex_control(1, 1); } }       {SQLITE_OK}
+do_test multiplex-1.12.5  { execsql { SELECT multiplex_control(1, -1); } }      {SQLITE_OK}
+do_test multiplex-1.12.6  { db close }                                          {}
+do_test multiplex-1.12.7  { sqlite3_multiplex_shutdown }                        {SQLITE_OK}
 
 #-------------------------------------------------------------------------
 # Some simple warm-body tests with a single database file in rollback 
@@ -104,7 +123,7 @@ do_test multiplex-1.10.9 { sqlite3_multiplex_shutdown }                       {S
 #
 #   multiplex-2.3.*: Open and close a second db.
 #
-#   multiplex-2.4.*: Try to shutdown the multiplex system befor e closing the db
+#   multiplex-2.4.*: Try to shutdown the multiplex system before closing the db
 #                file. Check that this fails and the multiplex system still works
 #                afterwards. Then close the database and successfully shut
 #                down the multiplex system.
@@ -113,6 +132,9 @@ do_test multiplex-1.10.9 { sqlite3_multiplex_shutdown }                       {S
 #
 #   multiplex-2.6.*: More reading/writing with varying small chunk sizes, as
 #                well as varying journal mode.
+#
+#   multiplex-2.7.*: Disable/enable tests.
+#
 
 sqlite3_multiplex_initialize "" 1
 multiplex_set db main 32768 16
@@ -261,6 +283,32 @@ foreach jmode $all_journal_modes {
   }
 }
 
+do_test multiplex-2.7.1  { multiplex_delete test.db }                          {}
+do_test multiplex-2.7.2  { sqlite3_multiplex_initialize "" 1 }                 {SQLITE_OK}
+do_test multiplex-2.7.3  { sqlite3 db test.db }                                {}
+do_test multiplex-2.7.4  { execsql { SELECT multiplex_control(2, 65536); } }   {SQLITE_OK}
+do_test multiplex-2.7.5  { execsql { SELECT multiplex_control(1, 0); } }       {SQLITE_OK}
+do_test multiplex-2.7.6 { 
+  execsql { 
+    CREATE TABLE t1(a PRIMARY KEY, b);
+    INSERT INTO t1 VALUES(1, randomblob(1000));
+  }
+} {}
+# verify only one file, and file size is less than chunks size
+do_test multiplex-2.7.7  { expr ([file size [multiplex_name test.db 0]] < 65536) } {1}
+do_test multiplex-2.7.8  { file exists [multiplex_name test.db 1] }                {0}
+do_test multiplex-2.7.9 { 
+  execsql { 
+    INSERT INTO t1 VALUES(1, randomblob(65536));
+  }
+} {}
+# verify only one file, and file size exceeds chunks size
+do_test multiplex-2.7.10 { expr ([file size [multiplex_name test.db 0]] > 65536) } {1}
+do_test multiplex-2.7.11 { file exists [multiplex_name test.db 1] }                {0}
+do_test multiplex-2.7.12 { db close }                                              {}
+do_test multiplex-2.7.13 { sqlite3_multiplex_shutdown }                            {SQLITE_OK}
+
+
 #-------------------------------------------------------------------------
 # Try some tests with more than one connection to a database file. Still
 # in rollback mode.