/ 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 Unified Diffs Ignore Whitespace Patch

Changes to src/test_multiplex.c.

449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
...
509
510
511
512
513
514
515


516

517
518
519
520

521

522














523

524
525


526
527
528
529
530
531
532
...
776
777
778
779
780
781
782

783
784
785
786
787
788
789
790
791
792
793
  sqlite3_file *pConn,       /* Fill in this file descriptor */
  int flags,                 /* Flags to control the opening */
  int *pOutFlags             /* Flags showing results of opening */
){
  int rc = SQLITE_OK;                  /* Result code */
  multiplexConn *pMultiplexOpen;       /* The new multiplex file descriptor */
  multiplexGroup *pGroup;              /* Corresponding multiplexGroup object */
  sqlite3_file *pSubOpen;                        /* Real file descriptor */
  sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
  int nName;
  int sz;
  char *zToFree = 0;

  UNUSED_PARAMETER(pVfs);
  memset(pConn, 0, pVfs->szOsFile);
................................................................................
      }
    }
    pGroup->zName = p;
    /* save off base filename, name length, and original open flags  */
    memcpy(pGroup->zName, zName, nName+1);
    pGroup->nName = nName;
    pGroup->flags = flags;


    pSubOpen = multiplexSubOpen(pGroup, 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{
        pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV2;
      }
      /* place this group at the head of our list */
      pGroup->pNext = gMultiplex.pGroups;
................................................................................
    sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL);
    if( pSubOpen==0 ){
      rc = SQLITE_IOERR_FSTAT;
    }else{
      rc = pSubOpen->pMethods->xFileSize(pSubOpen, pSize);
    }
  }else{

    *pSize = 0;
    for(i=0; 1; i++){
      sqlite3_file *pSubOpen = 0;
      sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;
      int exists = 0;
      rc = multiplexSubFilename(pGroup, i);
      if( rc ) break;
      rc2 = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[i].z,
          SQLITE_ACCESS_EXISTS, &exists);
      if( rc2==SQLITE_OK && exists){
        /* if it exists, open it */







|







 







>
>
|
>

<
<
<
>

>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
|
>
>







 







>



<







449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
...
509
510
511
512
513
514
515
516
517
518
519
520



521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
...
795
796
797
798
799
800
801
802
803
804
805

806
807
808
809
810
811
812
  sqlite3_file *pConn,       /* Fill in this file descriptor */
  int flags,                 /* Flags to control the opening */
  int *pOutFlags             /* Flags showing results of opening */
){
  int rc = SQLITE_OK;                  /* Result code */
  multiplexConn *pMultiplexOpen;       /* The new multiplex file descriptor */
  multiplexGroup *pGroup;              /* Corresponding multiplexGroup object */
  sqlite3_file *pSubOpen = 0;                    /* Real file descriptor */
  sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */
  int nName;
  int sz;
  char *zToFree = 0;

  UNUSED_PARAMETER(pVfs);
  memset(pConn, 0, pVfs->szOsFile);
................................................................................
      }
    }
    pGroup->zName = p;
    /* save off base filename, name length, and original open flags  */
    memcpy(pGroup->zName, zName, nName+1);
    pGroup->nName = nName;
    pGroup->flags = flags;
    rc = multiplexSubFilename(pGroup, 1);
    if( rc==SQLITE_OK ){
      pSubOpen = multiplexSubOpen(pGroup, 0, &rc, pOutFlags);
    }
    if( pSubOpen ){



      int exists, rc2, rc3;
      sqlite3_int64 sz;

      rc2 = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);
      if( rc2==SQLITE_OK ){
        /* If the first overflow file exists and if the size of the main file
        ** is different from the chunk size, that means the chunk size is set
        ** set incorrectly.  So fix it.
        **
        ** Or, if the first overflow file does not exist and the main file is
        ** larger than the chunk size, that means the chunk size is too small.
        ** But we have no way of determining the intended chunk size, so 
        ** just disable the multiplexor all togethre.
        */
        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 ){
          pGroup->bEnabled = 0;
        }
      }

      if( pSubOpen->pMethods->iVersion==1 ){
        pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV1;
      }else{
        pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV2;
      }
      /* place this group at the head of our list */
      pGroup->pNext = gMultiplex.pGroups;
................................................................................
    sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL);
    if( pSubOpen==0 ){
      rc = SQLITE_IOERR_FSTAT;
    }else{
      rc = pSubOpen->pMethods->xFileSize(pSubOpen, pSize);
    }
  }else{
    sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;
    *pSize = 0;
    for(i=0; 1; i++){
      sqlite3_file *pSubOpen = 0;

      int exists = 0;
      rc = multiplexSubFilename(pGroup, i);
      if( rc ) break;
      rc2 = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[i].z,
          SQLITE_ACCESS_EXISTS, &exists);
      if( rc2==SQLITE_OK && exists){
        /* if it exists, open it */