Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch range-delete-fixes Excluding Merge-Ins
This is equivalent to a diff from 9d8943da66 to 3ba1c3f589
2012-11-05
| ||
14:56 | Merge range-delete-fixes branch with trunk. check-in: 7605250294 user: dan tags: trunk | |
14:33 | Before writing data to a new database segment, make sure the data is held in heap (not mmap'd) memory. Otherwise, the write may cause the file to grow and the mapping to be released and remapped, leaving an invalid pointer. Leaf check-in: 3ba1c3f589 user: dan tags: range-delete-fixes | |
10:23 | Fix a bug in compressed database mode causing an incorrect page number to be assigned to a page record when the end of the previous record is aligned with the end of a database block. check-in: e6a71a8583 user: dan tags: range-delete-fixes | |
2012-11-02
| ||
20:13 | Change free-list deletes to use range-deletes instead of point-deletes (so that they can be coalesced when segments are merged). This has revealed problems with the range-delete code. check-in: 9374c3a283 user: dan tags: range-delete-fixes | |
2012-11-01
| ||
15:16 | Fix a bug preventing a modified snapshot of a "full" database from being written to shared-memory. check-in: 9d8943da66 user: dan tags: trunk | |
05:00 | Re-enable incremental recycling of blocks belonging to segments for which the b-tree hierarchy is still in use. check-in: 41bf1ae58d user: dan tags: trunk | |
Changes to lsm-test/lsmtest.h.
︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | + | TestDb *testOpen(const char *zSystem, int, int *pRc); void testReopen(TestDb **ppDb, int *pRc); void testClose(TestDb **ppDb); void testFetch(TestDb *, void *, int, void *, int, int *); void testWrite(TestDb *, void *, int, void *, int, int *); void testDelete(TestDb *, void *, int, int *); void testDeleteRange(TestDb *, void *, int, void *, int, int *); void testWriteStr(TestDb *, const char *, const char *zVal, int *pRc); void testFetchStr(TestDb *, const char *, const char *, int *pRc); void testBegin(TestDb *pDb, int iTrans, int *pRc); void testCommit(TestDb *pDb, int iTrans, int *pRc); void test_failed(void); |
︙ | |||
196 197 198 199 200 201 202 203 204 205 206 207 208 209 | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | + | void testDeleteDatasource(TestDb *, Datasource *, int, int *); void testDeleteDatasourceRange(TestDb *, Datasource *, int, int, int *); /* test1.c */ void test_data_1(const char *, const char *, int *pRc); void test_data_2(const char *, const char *, int *pRc); void test_data_3(const char *, const char *, int *pRc); void testDbContents(TestDb *, Datasource *, int, int, int, int, int, int *); void testCaseProgress(int, int, int, int *); int testCaseNDot(void); typedef struct CksumDb CksumDb; CksumDb *testCksumArrayNew(Datasource *, int, int, int); char *testCksumArrayGet(CksumDb *, int); |
︙ |
Changes to lsm-test/lsmtest1.c.
︙ | |||
481 482 483 484 485 486 487 488 | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 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 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | char *zName = getName2(zSystem, &aTest[i]); if( testCaseBegin(pRc, zPattern, "%s", zName) ){ doDataTest2(zSystem, &aTest[i], pRc); } testFree(zName); } } /************************************************************************* ** Test case data3.* */ typedef struct Datatest3 Datatest3; struct Datatest3 { int nRange; /* Keys are between 1 and this value, incl. */ int nIter; /* Number of iterations */ int nWrite; /* Number of writes per iteration */ int nDelete; /* Number of deletes per iteration */ int nValMin; /* Minimum value size for writes */ int nValMax; /* Maximum value size for writes */ }; void testPutU32(u8 *aBuf, u32 iVal){ aBuf[0] = (iVal >> 24) & 0xFF; aBuf[1] = (iVal >> 16) & 0xFF; aBuf[2] = (iVal >> 8) & 0xFF; aBuf[3] = (iVal >> 0) & 0xFF; } void dt3PutKey(u8 *aBuf, int iKey){ assert( iKey<100000 && iKey>=0 ); sprintf((char *)aBuf, "%.5d", iKey); } static void doDataTest3( const char *zSystem, /* Database system to test */ Datatest3 *p, /* Structure containing test parameters */ int *pRc /* OUT: Error code */ ){ int iDot = 0; int rc = *pRc; TestDb *pDb; u8 *abPresent; /* Array of boolean */ char *aVal; /* Buffer to hold values */ int i; u32 iSeq = 10; /* prng counter */ abPresent = (u8 *)testMalloc(p->nRange+1); aVal = (char *)testMalloc(p->nValMax+1); pDb = testOpen(zSystem, 1, &rc); for(i=0; i<p->nIter && rc==0; i++){ int ii; testCaseProgress(i, p->nIter, testCaseNDot(), &iDot); /* Perform nWrite inserts */ for(ii=0; ii<p->nWrite; ii++){ u8 aKey[6]; u32 iKey; int nVal; iKey = (testPrngValue(iSeq++) % p->nRange) + 1; nVal = (testPrngValue(iSeq++) % (p->nValMax - p->nValMin)) + p->nValMin; testPrngString(testPrngValue(iSeq++), aVal, nVal); dt3PutKey(aKey, iKey); testWrite(pDb, aKey, sizeof(aKey)-1, aVal, nVal, &rc); abPresent[iKey] = 1; } /* Perform nDelete deletes */ for(ii=0; ii<p->nDelete; ii++){ u8 aKey1[6]; u8 aKey2[6]; u32 iKey; iKey = (testPrngValue(iSeq++) % p->nRange) + 1; dt3PutKey(aKey1, iKey-1); dt3PutKey(aKey2, iKey+1); testDeleteRange(pDb, aKey1, sizeof(aKey1)-1, aKey2, sizeof(aKey2)-1, &rc); abPresent[iKey] = 0; } testReopen(&pDb, &rc); for(ii=1; rc==0 && ii<=p->nRange; ii++){ int nDbVal; void *pDbVal; u8 aKey[6]; int dbrc; dt3PutKey(aKey, ii); dbrc = tdb_fetch(pDb, aKey, sizeof(aKey)-1, &pDbVal, &nDbVal); testCompareInt(0, dbrc, &rc); if( abPresent[ii] ){ testCompareInt(1, (nDbVal>0), &rc); }else{ testCompareInt(1, (nDbVal<0), &rc); } } } testClose(&pDb); testCaseFinish(rc); *pRc = rc; } static char *getName3(const char *zSystem, Datatest3 *p){ return testMallocPrintf("data3.%s.%d.%d.%d.%d.(%d..%d)", zSystem, p->nRange, p->nIter, p->nWrite, p->nDelete, p->nValMin, p->nValMax ); } void test_data_3( const char *zSystem, /* Database system name */ const char *zPattern, /* Run test cases that match this pattern */ int *pRc /* IN/OUT: Error code */ ){ Datatest3 aTest[] = { /* nRange, nIter, nWrite, nDelete, nValMin, nValMax */ { 100, 1000, 5, 5, 50, 100 }, { 100, 1000, 2, 2, 5, 10 }, }; int i; for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){ char *zName = getName3(zSystem, &aTest[i]); if( testCaseBegin(pRc, zPattern, "%s", zName) ){ doDataTest3(zSystem, &aTest[i], pRc); } testFree(zName); } } |
Changes to lsm-test/lsmtest_main.c.
︙ | |||
458 459 460 461 462 463 464 465 466 467 468 469 470 471 | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | + | } for(j=0; tdb_system_name(j); j++){ rc = 0; test_data_1(tdb_system_name(j), zPattern, &rc); test_data_2(tdb_system_name(j), zPattern, &rc); test_data_3(tdb_system_name(j), zPattern, &rc); test_rollback(tdb_system_name(j), zPattern, &rc); test_mc(tdb_system_name(j), zPattern, &rc); test_mt(tdb_system_name(j), zPattern, &rc); if( rc ) nFail++; } |
︙ |
Changes to lsm-test/lsmtest_tdb3.c.
︙ | |||
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | + + + + + + + + - + | zStart = z; while( *z && *z!='=' ) z++; if( *z ){ int eParam; int i; int iVal; int iMul = 1; int rc; char zParam[32]; int nParam = z-zStart; if( nParam==0 || nParam>sizeof(zParam)-1 ) goto syntax_error; memcpy(zParam, zStart, nParam); zParam[nParam] = '\0'; rc = testArgSelect(aParam, "param", zParam, &i); if( rc!=0 ) return rc; eParam = aParam[i].eParam; z++; zStart = z; while( *z>='0' && *z<='9' ) z++; if( *z=='k' || *z=='K' ){ iMul = 1024; z++; }else if( *z=='M' || *z=='M' ){ iMul = 1024 * 1024; z++; } nParam = z-zStart; if( nParam==0 || nParam>sizeof(zParam)-1 ) goto syntax_error; memcpy(zParam, zStart, nParam); zParam[nParam] = '\0'; |
︙ |
Changes to src/lsm.h.
︙ | |||
480 481 482 483 484 485 486 487 488 489 490 491 492 493 | 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | + + | ** can be found. This is usually used to optimize the database by ** merging the whole thing into one big array. */ int lsm_work(lsm_db *pDb, int flags, int nPage, int *pnWrite); #define LSM_WORK_FLUSH 0x00000001 #define LSM_WORK_OPTIMIZE 0x00000002 int lsm_flush(lsm_db *pDb); /* ** Attempt to checkpoint the current database snapshot. Return an LSM ** error code if an error occurs or LSM_OK otherwise. ** ** If the current snapshot has already been checkpointed, calling this ** function is a no-op. In this case if pnByte is not NULL, *pnByte is |
︙ |
Changes to src/lsmInt.h.
︙ | |||
528 529 530 531 532 533 534 | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | - | /* ** Functions from file "lsm_tree.c". */ int lsmTreeNew(lsm_env *, int (*)(void *, int, void *, int), Tree **ppTree); void lsmTreeRelease(lsm_env *, Tree *); |
︙ |
Changes to src/lsm_file.c.
︙ | |||
1827 1828 1829 1830 1831 1832 1833 | 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 | - + | rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iWrite-4, aPtr, sizeof(aPtr)); if( nRem>0 ) iApp = iWrite; } }else{ /* The next block is already allocated. */ assert( nRem>0 ); rc = fsBlockNext(pFS, fsPageToBlock(pFS, iApp), &iBlk); |
︙ |
Changes to src/lsm_sorted.c.
︙ | |||
180 181 182 183 184 185 186 187 188 189 190 191 192 193 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | + + + + + | ** lsmMCursorNext() ** lsmMCursorPrev() ** lsmMCursorFirst() ** lsmMCursorLast() ** lsmMCursorKey() ** lsmMCursorValue() ** lsmMCursorValid() ** ** iFree: ** This variable is only used by cursors providing input data for a ** new top-level segment. Such cursors only ever iterate forwards, not ** backwards. */ struct MultiCursor { lsm_db *pDb; /* Connection that owns this cursor */ MultiCursor *pNext; /* Next cursor owned by connection pDb */ int flags; /* Mask of CURSOR_XXX flags */ int eType; /* Cache of current key type */ |
︙ | |||
1905 1906 1907 1908 1909 1910 1911 | 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 | - - + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | lsmTreeCursorValue(pTreeCsr, &pVal, &nVal); } break; } case CURSOR_DATA_SYSTEM: { Snapshot *pWorker = pCsr->pDb->pWorker; |
︙ | |||
1950 1951 1952 1953 1954 1955 1956 | 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 | - + + - - + + + - - - - + + + + + | if( peType ) *peType = eType; if( pnKey ) *pnKey = nKey; if( ppKey ) *ppKey = pKey; } static int sortedDbKeyCompare( |
︙ | |||
2008 2009 2010 2011 2012 2013 2014 | 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 | - + + + + + + + - + | iRes = i2; }else if( pKey2==0 ){ iRes = i1; }else{ int res; /* Compare the keys */ |
︙ | |||
2313 2314 2315 2316 2317 2318 2319 | 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 | - - + + + + + | *pnVal = 0; } break; } case CURSOR_DATA_SYSTEM: { Snapshot *pWorker = pCsr->pDb->pWorker; |
︙ | |||
2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 | 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } if( (pCsr->flags & CURSOR_IGNORE_SYSTEM) && rtTopic(eType)!=0 ){ return 0; } /* Check if this key has already been deleted by a range-delete */ iKey = pCsr->aTree[1]; for(i=0; i<iKey; i++){ int csrflags; multiCursorGetKey(pCsr, i, &csrflags, 0, 0); if( (rdmask & csrflags) ){ const int SD_ED = (LSM_START_DELETE|LSM_END_DELETE); if( (csrflags & SD_ED)==SD_ED || (pCsr->flags & CURSOR_IGNORE_DELETE)==0 ){ void *pKey; int nKey; multiCursorGetKey(pCsr, i, 0, &pKey, &nKey); if( 0==sortedKeyCompare(pCsr->pDb->xCmp, rtTopic(eType), pCsr->key.pData, pCsr->key.nData, rtTopic(csrflags), pKey, nKey )){ continue; } } return 0; } } #if 0 if( (iKey>0 && (rdmask & lsmTreeCursorFlags(pCsr->apTreeCsr[0]))) || (iKey>1 && (rdmask & lsmTreeCursorFlags(pCsr->apTreeCsr[1]))) ){ return 0; } if( iKey>CURSOR_DATA_SYSTEM && (pCsr->flags & CURSOR_FLUSH_FREELIST) ){ int eType; multiCursorGetKey(pCsr, CURSOR_DATA_SYSTEM, &eType, 0, 0); if( rdmask & eType ) return 0; } for(i=CURSOR_DATA_SEGMENT; i<iKey; i++){ int iPtr = i-CURSOR_DATA_SEGMENT; if( pCsr->aPtr[iPtr].pPg && (pCsr->aPtr[iPtr].eType & rdmask) ){ return 0; } } #endif return 1; } static int multiCursorEnd(MultiCursor *pCsr, int bLast){ int rc = LSM_OK; int i; |
︙ | |||
2764 2765 2766 2767 2768 2769 2770 | 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 | + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | /* Check the current key value. If it is not greater than (if bReverse==0) ** or less than (if bReverse!=0) the key currently cached in pCsr->key, ** then the cursor has not yet been successfully advanced. */ multiCursorGetKey(pCsr, pCsr->aTree[1], &eNewType, &pNew, &nNew); if( pNew ){ int typemask = (pCsr->flags & CURSOR_IGNORE_DELETE) ? ~(0) : LSM_SYSTEMKEY; |
︙ | |||
2817 2818 2819 2820 2821 2822 2823 | 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 | - + | rc = lsmTreeCursorPrev(pTreeCsr); }else{ rc = lsmTreeCursorNext(pTreeCsr); } }else if( iKey==CURSOR_DATA_SYSTEM ){ assert( pCsr->flags & CURSOR_FLUSH_FREELIST ); assert( bReverse==0 ); |
︙ | |||
2846 2847 2848 2849 2850 2851 2852 | 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 | - + | int lsmMCursorPrev(MultiCursor *pCsr){ if( (pCsr->flags & CURSOR_PREV_OK)==0 ) return LSM_MISUSE_BKPT; return multiCursorAdvance(pCsr, 1); } int lsmMCursorKey(MultiCursor *pCsr, void **ppKey, int *pnKey){ |
︙ | |||
2883 2884 2885 2886 2887 2888 2889 | 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 | - + | return LSM_OK; } int lsmMCursorValue(MultiCursor *pCsr, void **ppVal, int *pnVal){ void *pVal; int nVal; int rc; |
︙ | |||
3515 3516 3517 3518 3519 3520 3521 | 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 | - + - - | return rc; } static int mergeWorkerWrite( MergeWorker *pMW, /* Merge worker object to write into */ int eType, /* One of SORTED_SEPARATOR, WRITE or DELETE */ void *pKey, int nKey, /* Key value */ |
︙ | |||
3563 3564 3565 3566 3567 3568 3569 | 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 | - - - - + | ** The header space is: ** ** 1) record type - 1 byte. ** 2) Page-pointer-offset - 1 varint ** 3) Key size - 1 varint ** 4) Value size - 1 varint (only if LSM_INSERT flag is set) */ |
︙ | |||
3623 3624 3625 3626 3627 3628 3629 | 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 | - | if( rtIsWrite(eType) ) iOff += lsmVarintPut32(&aData[iOff], nVal); /* 4 */ pMerge->iOutputOff = iOff; /* Write the key and data into the segment. */ assert( iFPtr==pageGetPtr(aData, nData) ); rc = mergeWorkerData(pMW, 0, iFPtr+iRPtr, pKey, nKey); if( rc==LSM_OK && rtIsWrite(eType) ){ |
︙ | |||
3723 3724 3725 3726 3727 3728 3729 | 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 | - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + | ** a merge operation. When this function is called, *piFlags contains the ** database entry flags for the current entry. The entry about to be written ** to the output. ** ** Note that this function only has to work for cursors configured to ** iterate forwards (not backwards). */ |
︙ | |||
3803 3804 3805 3806 3807 3808 3809 | 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 | + - + - + + + + + + + + - + | if( pPtr->pPg && 0==pDb->xCmp(pPtr->pKey, pPtr->nKey, pKey, nKey) ){ iPtr = pPtr->iPtr+pPtr->iPgPtr; } } iVal = pCsr->aTree[1]; |
︙ | |||
3968 3969 3970 3971 3972 3973 3974 | 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 | - + | assert( rc!=LSM_OK || pDb->pWorker->freelist.nEntry==0 ); lsmDbSnapshotSetLevel(pDb->pWorker, pNext); sortedFreeLevel(pDb->pEnv, pNew); }else{ if( pDel ) pDel->iRoot = 0; #if 0 |
︙ | |||
4385 4386 4387 4388 4389 4390 4391 | 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 | - + | /* Clean up the MergeWorker object initialized above. If no error ** has occurred, invoke the work-hook to inform the application that ** the database structure has changed. */ mergeWorkerShutdown(&mergeworker, &rc); if( rc==LSM_OK ) sortedInvokeWorkHook(pDb); #if 0 |
︙ | |||
4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 | 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 | + + + + + + + + + + + + + + + + + + + + + + + + + | /* This function may not be called if pDb has an open read or write ** transaction. Return LSM_MISUSE if an application attempts this. */ if( pDb->nTransOpen || pDb->pCsr ) return LSM_MISUSE_BKPT; return doLsmWork(pDb, flags, nPage, pnWrite); } int lsm_flush(lsm_db *db){ int rc; if( db->nTransOpen>0 || db->pCsr ){ rc = LSM_MISUSE_BKPT; }else{ rc = lsmBeginWriteTrans(db); if( rc==LSM_OK ){ lsmFlushTreeToDisk(db); lsmTreeDiscardOld(db); lsmTreeMakeOld(db); lsmTreeDiscardOld(db); } if( rc==LSM_OK ){ rc = lsmFinishWriteTrans(db, 1); }else{ lsmFinishWriteTrans(db, 0); } lsmFinishReadTrans(db); } return rc; } /* ** This function is called in auto-work mode to perform merging work on ** the data structure. It performs enough merging work to prevent the ** height of the tree from growing indefinitely assuming that roughly ** nUnit database pages worth of data have been written to the database ** (i.e. the in-memory tree) since the last call. |
︙ |
Changes to src/lsm_tree.c.
︙ | |||
1047 1048 1049 1050 1051 1052 1053 | 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 | - - - - - - - - - - - | rc = treeUpdatePtr(pDb, pCsr, iNew); } } return rc; } |
︙ |
Added test/lsm1.test.