SQLite4
Check-in [a92d659eee]
Not logged in

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

Overview
SHA1 Hash:a92d659eee6a7d91236a91274357fb1194c45c54
Date: 2013-03-02 16:01:39
User: dan
Comment:Fix some problems on this branch.
Tags And Properties
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/lsm_file.c

653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
...
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
...
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
...
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
  int rc = *pRc;

  assert( iOff>=0 && nByte>0 );
  assert( p->eUseMmap!=LSM_MMAP_OFF );
  assert( *ppRef==0 );

  if( p->eUseMmap==LSM_MMAP_FULL ){
    fsGrowMapping(pFS, iOff+nByte, &rc);
    if( rc==LSM_OK ){
      pRet = (void *)&((u8 *)p->pMap)[iOff];
      *ppRef = (MmapMgrRef *)pRet;
    }
  }else{
    MmapMgrRef *pRef = 0;         /* Mapping reference */

................................................................................
    pFS->nMetasize = 4 * 1024;
    pFS->pDb = pDb;
    pFS->pEnv = pDb->pEnv;
    if( !pDb->compress.xCompress ){
      pFS->mmapmgr.eUseMmap = pDb->eMmap;
      pFS->mmapmgr.nMapsz = 1*1024*1024;

      pFS->mmapmgr.nMapsz = 4*1024;
    }

    /* Make a copy of the database and log file names. */
    memcpy(pFS->zDb, zDb, nDb+1);
    memcpy(pFS->zLog, zDb, nDb);
    memcpy(&pFS->zLog[nDb], "-log", 5);

................................................................................

    /* Reset any compression/decompression buffers already allocated */
    lsmFree(pEnv, pFS->aIBuffer);
    lsmFree(pEnv, pFS->aOBuffer);
    pFS->nBuffer = 0;

    /* Unmap the file, if it is currently mapped */
    if( pFS->pMap ){
      lsmEnvRemap(pEnv, pFS->fdDb, -1, &pFS->pMap, &pFS->nMap);
      pFS->bUseMmap = 0;
    }

    /* Free all allocate page structures */
    pPg = pFS->pLruFirst;
    while( pPg ){
      Page *pNext = pPg->pLruNext;
      if( pPg->flags & PAGE_FREE ) lsmFree(pEnv, pPg->aData);
      lsmFree(pEnv, pPg);
................................................................................
    pFS->pLruFirst = 0;
    pFS->pLruLast = 0;
    pFS->pFree = 0;

    /* Configure the FileSystem object */
    if( db->compress.xCompress ){
      pFS->pCompress = &db->compress;
      pFS->bUseMmap = 0;
    }else{
      pFS->pCompress = 0;
      pFS->bUseMmap = db->bMmap;
    }
  }

  return LSM_OK;
}

/*







|







 







|







 







|
<
<
<







 







|


|







653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
...
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
...
927
928
929
930
931
932
933
934



935
936
937
938
939
940
941
...
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
  int rc = *pRc;

  assert( iOff>=0 && nByte>0 );
  assert( p->eUseMmap!=LSM_MMAP_OFF );
  assert( *ppRef==0 );

  if( p->eUseMmap==LSM_MMAP_FULL ){
    fsGrowMapping(pFS, LSM_MAX(iOff+nByte, 8192), &rc);
    if( rc==LSM_OK ){
      pRet = (void *)&((u8 *)p->pMap)[iOff];
      *ppRef = (MmapMgrRef *)pRet;
    }
  }else{
    MmapMgrRef *pRef = 0;         /* Mapping reference */

................................................................................
    pFS->nMetasize = 4 * 1024;
    pFS->pDb = pDb;
    pFS->pEnv = pDb->pEnv;
    if( !pDb->compress.xCompress ){
      pFS->mmapmgr.eUseMmap = pDb->eMmap;
      pFS->mmapmgr.nMapsz = 1*1024*1024;

      /* pFS->mmapmgr.nMapsz = 4*1024; */
    }

    /* Make a copy of the database and log file names. */
    memcpy(pFS->zDb, zDb, nDb+1);
    memcpy(pFS->zLog, zDb, nDb);
    memcpy(&pFS->zLog[nDb], "-log", 5);

................................................................................

    /* Reset any compression/decompression buffers already allocated */
    lsmFree(pEnv, pFS->aIBuffer);
    lsmFree(pEnv, pFS->aOBuffer);
    pFS->nBuffer = 0;

    /* Unmap the file, if it is currently mapped */
    fsMmapClose(pFS);




    /* Free all allocate page structures */
    pPg = pFS->pLruFirst;
    while( pPg ){
      Page *pNext = pPg->pLruNext;
      if( pPg->flags & PAGE_FREE ) lsmFree(pEnv, pPg->aData);
      lsmFree(pEnv, pPg);
................................................................................
    pFS->pLruFirst = 0;
    pFS->pLruLast = 0;
    pFS->pFree = 0;

    /* Configure the FileSystem object */
    if( db->compress.xCompress ){
      pFS->pCompress = &db->compress;
      pFS->mmapmgr.eUseMmap = LSM_MMAP_OFF;
    }else{
      pFS->pCompress = 0;
      pFS->mmapmgr.eUseMmap = db->eMmap;
    }
  }

  return LSM_OK;
}

/*

Changes to src/lsm_main.c

325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
      }
      *piVal = pDb->eSafety;
      break;
    }

    case LSM_CONFIG_MMAP: {
      int *piVal = va_arg(ap, int *);
      if( pDb->iReader<0 && *piVal>=0 && *piVal<=1 ){
        pDb->bMmap = *piVal;
        rc = lsmFsConfigure(pDb);
      }
      *piVal = pDb->eMmap;
      break;
    }

    case LSM_CONFIG_USE_LOG: {







|
|







325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
      }
      *piVal = pDb->eSafety;
      break;
    }

    case LSM_CONFIG_MMAP: {
      int *piVal = va_arg(ap, int *);
      if( pDb->iReader<0 && *piVal>=0 && *piVal<=2 ){
        pDb->eMmap = *piVal;
        rc = lsmFsConfigure(pDb);
      }
      *piVal = pDb->eMmap;
      break;
    }

    case LSM_CONFIG_USE_LOG: {

Changes to src/lsm_sorted.c

700
701
702
703
704
705
706
707
708

709
710
711
712
713
714
715
    ** the left-most most descendent. */
    if( pCsr->iPg>=0 ){
      pCsr->aPg[pCsr->iPg].iCell++;

      iLoad = btreeCursorPtr(aData, nData, pPg->iCell);
      do {
        Page *pLoad;
        pCsr->iPg++;
        rc = lsmFsDbPageGet(pCsr->pFS, pCsr->pSeg, iLoad, &pLoad);

        pCsr->aPg[pCsr->iPg].pPage = pLoad;
        pCsr->aPg[pCsr->iPg].iCell = 0;
        if( rc==LSM_OK ){
          if( pCsr->iPg==(pCsr->nDepth-1) ) break;
          aData = fsPageData(pLoad, &nData);
          iLoad = btreeCursorPtr(aData, nData, 0);
        }







<

>







700
701
702
703
704
705
706

707
708
709
710
711
712
713
714
715
    ** the left-most most descendent. */
    if( pCsr->iPg>=0 ){
      pCsr->aPg[pCsr->iPg].iCell++;

      iLoad = btreeCursorPtr(aData, nData, pPg->iCell);
      do {
        Page *pLoad;

        rc = lsmFsDbPageGet(pCsr->pFS, pCsr->pSeg, iLoad, &pLoad);
        pCsr->iPg++;
        pCsr->aPg[pCsr->iPg].pPage = pLoad;
        pCsr->aPg[pCsr->iPg].iCell = 0;
        if( rc==LSM_OK ){
          if( pCsr->iPg==(pCsr->nDepth-1) ) break;
          aData = fsPageData(pLoad, &nData);
          iLoad = btreeCursorPtr(aData, nData, 0);
        }