/ Check-in [427a9a51]
Login

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

Overview
Comment:For an existing multiplexed database, try to set the chunk size automatically based on the sizes of the preexisting pieces.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 427a9a5120a68bfa12fec97cfd02eb9b28b3fa6b
User & Date: drh 2011-07-20 17:59:38
Context
2011-07-21
20:59
All multiplexor chunk sizes up to 4GiB. Disable the multiplexor if the chunk size is set to 0. check-in: 83191ad6 user: drh tags: trunk
2011-07-20
17:59
For an existing multiplexed database, try to set the chunk size automatically based on the sizes of the preexisting pieces. check-in: 427a9a51 user: drh tags: trunk
17:13
All the SQLITE_OPEN_URI flag to propagate down into the VFS. check-in: 29866f95 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_multiplex.c.

   449    449     sqlite3_file *pConn,       /* Fill in this file descriptor */
   450    450     int flags,                 /* Flags to control the opening */
   451    451     int *pOutFlags             /* Flags showing results of opening */
   452    452   ){
   453    453     int rc = SQLITE_OK;                  /* Result code */
   454    454     multiplexConn *pMultiplexOpen;       /* The new multiplex file descriptor */
   455    455     multiplexGroup *pGroup;              /* Corresponding multiplexGroup object */
   456         -  sqlite3_file *pSubOpen;                        /* Real file descriptor */
          456  +  sqlite3_file *pSubOpen = 0;                    /* Real file descriptor */
   457    457     sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
   458    458     int nName;
   459    459     int sz;
   460    460     char *zToFree = 0;
   461    461   
   462    462     UNUSED_PARAMETER(pVfs);
   463    463     memset(pConn, 0, pVfs->szOsFile);
................................................................................
   509    509         }
   510    510       }
   511    511       pGroup->zName = p;
   512    512       /* save off base filename, name length, and original open flags  */
   513    513       memcpy(pGroup->zName, zName, nName+1);
   514    514       pGroup->nName = nName;
   515    515       pGroup->flags = flags;
   516         -    pSubOpen = multiplexSubOpen(pGroup, 0, &rc, pOutFlags);
          516  +    rc = multiplexSubFilename(pGroup, 1);
          517  +    if( rc==SQLITE_OK ){
          518  +      pSubOpen = multiplexSubOpen(pGroup, 0, &rc, pOutFlags);
          519  +    }
   517    520       if( pSubOpen ){
   518         -      /* if this file is already larger than chunk size, disable 
   519         -      ** the multiplex feature.
   520         -      */
          521  +      int exists, rc2, rc3;
   521    522         sqlite3_int64 sz;
   522         -      int rc2 = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
   523         -      if( (rc2==SQLITE_OK) && (sz>pGroup->nChunkSize) ){
   524         -        pGroup->bEnabled = 0;
          523  +
          524  +      rc2 = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
          525  +      if( rc2==SQLITE_OK ){
          526  +        /* If the first overflow file exists and if the size of the main file
          527  +        ** is different from the chunk size, that means the chunk size is set
          528  +        ** set incorrectly.  So fix it.
          529  +        **
          530  +        ** Or, if the first overflow file does not exist and the main file is
          531  +        ** larger than the chunk size, that means the chunk size is too small.
          532  +        ** But we have no way of determining the intended chunk size, so 
          533  +        ** just disable the multiplexor all togethre.
          534  +        */
          535  +        rc3 = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[1].z,
          536  +            SQLITE_ACCESS_EXISTS, &exists);
          537  +        if( rc3==SQLITE_OK && exists && sz==(sz&0xffff0000) && sz>0
          538  +            && sz!=pGroup->nChunkSize ){
          539  +          pGroup->nChunkSize = sz;
          540  +        }else if( rc3==SQLITE_OK && !exists && sz>pGroup->nChunkSize ){
          541  +          pGroup->bEnabled = 0;
          542  +        }
   525    543         }
          544  +
   526    545         if( pSubOpen->pMethods->iVersion==1 ){
   527    546           pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV1;
   528    547         }else{
   529    548           pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV2;
   530    549         }
   531    550         /* place this group at the head of our list */
   532    551         pGroup->pNext = gMultiplex.pGroups;
................................................................................
   776    795       sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL);
   777    796       if( pSubOpen==0 ){
   778    797         rc = SQLITE_IOERR_FSTAT;
   779    798       }else{
   780    799         rc = pSubOpen->pMethods->xFileSize(pSubOpen, pSize);
   781    800       }
   782    801     }else{
          802  +    sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;
   783    803       *pSize = 0;
   784    804       for(i=0; 1; i++){
   785    805         sqlite3_file *pSubOpen = 0;
   786         -      sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;
   787    806         int exists = 0;
   788    807         rc = multiplexSubFilename(pGroup, i);
   789    808         if( rc ) break;
   790    809         rc2 = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[i].z,
   791    810             SQLITE_ACCESS_EXISTS, &exists);
   792    811         if( rc2==SQLITE_OK && exists){
   793    812           /* if it exists, open it */