Fix an LSM problem caused by using the same cursor for equality and range
scans. FossilOrigin-Name: f05bead371d41ca5beef1f82e4c920c90e2eb9cd9fd537a5c91973bf9bd4eedb
This commit is contained in:
@@ -274,6 +274,7 @@ static void doDataTest1(
|
||||
int rc = LSM_OK;
|
||||
Datasource *pData;
|
||||
TestDb *pDb;
|
||||
int iToggle = 0;
|
||||
|
||||
/* Start the test case, open a database and allocate the datasource. */
|
||||
pDb = testOpen(zSystem, 1, &rc);
|
||||
@@ -287,8 +288,11 @@ static void doDataTest1(
|
||||
testWriteDatasourceRange(pDb, pData, i, p->nVerify, &rc);
|
||||
i += p->nVerify;
|
||||
|
||||
if( iToggle ) testBegin(pDb, 1, &rc);
|
||||
/* Check that the db content is correct. */
|
||||
testDbContents(pDb, pData, p->nRow, 0, i-1, p->nTest, p->bTestScan, &rc);
|
||||
if( iToggle ) testCommit(pDb, 0, &rc);
|
||||
iToggle = (iToggle+1)%2;
|
||||
|
||||
if( bRecover ){
|
||||
testReopenRecover(&pDb, &rc);
|
||||
|
||||
@@ -617,8 +617,12 @@ static int test_lsm_fetch(
|
||||
|
||||
if( pKey==0 ) return LSM_OK;
|
||||
|
||||
rc = lsm_csr_open(pDb->db, &csr);
|
||||
if( rc!=LSM_OK ) return rc;
|
||||
if( pDb->pCsr==0 ){
|
||||
rc = lsm_csr_open(pDb->db, &csr);
|
||||
if( rc!=LSM_OK ) return rc;
|
||||
}else{
|
||||
csr = pDb->pCsr;
|
||||
}
|
||||
|
||||
rc = lsm_csr_seek(csr, pKey, nKey, LSM_SEEK_EQ);
|
||||
if( rc==LSM_OK ){
|
||||
@@ -638,7 +642,9 @@ static int test_lsm_fetch(
|
||||
*pnVal = -1;
|
||||
}
|
||||
}
|
||||
lsm_csr_close(csr);
|
||||
if( pDb->pCsr==0 ){
|
||||
lsm_csr_close(csr);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -652,10 +658,16 @@ static int test_lsm_scan(
|
||||
){
|
||||
LsmDb *pDb = (LsmDb *)pTestDb;
|
||||
lsm_cursor *csr;
|
||||
lsm_cursor *csr2 = 0;
|
||||
int rc;
|
||||
|
||||
rc = lsm_csr_open(pDb->db, &csr);
|
||||
if( rc!=LSM_OK ) return rc;
|
||||
if( pDb->pCsr==0 ){
|
||||
rc = lsm_csr_open(pDb->db, &csr);
|
||||
if( rc!=LSM_OK ) return rc;
|
||||
}else{
|
||||
rc = LSM_OK;
|
||||
csr = pDb->pCsr;
|
||||
}
|
||||
|
||||
if( bReverse ){
|
||||
if( pLast ){
|
||||
@@ -696,7 +708,9 @@ static int test_lsm_scan(
|
||||
}
|
||||
}
|
||||
|
||||
lsm_csr_close(csr);
|
||||
if( pDb->pCsr==0 ){
|
||||
lsm_csr_close(csr);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -762,6 +776,7 @@ static void xWorkHook(lsm_db *db, void *pArg){
|
||||
#define TEST_MT_MIN_CKPT -4
|
||||
#define TEST_MT_MAX_CKPT -5
|
||||
|
||||
|
||||
int test_lsm_config_str(
|
||||
LsmDb *pLsm,
|
||||
lsm_db *db,
|
||||
|
||||
@@ -2868,7 +2868,7 @@ static int multiCursorEnd(MultiCursor *pCsr, int bLast){
|
||||
int rc = LSM_OK;
|
||||
int i;
|
||||
|
||||
pCsr->flags &= ~(CURSOR_NEXT_OK | CURSOR_PREV_OK);
|
||||
pCsr->flags &= ~(CURSOR_NEXT_OK | CURSOR_PREV_OK | CURSOR_SEEK_EQ);
|
||||
pCsr->flags |= (bLast ? CURSOR_PREV_OK : CURSOR_NEXT_OK);
|
||||
pCsr->iFree = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user