/ Check-in [f05bead3]
Login

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

Overview
Comment:Fix an LSM problem caused by using the same cursor for equality and range scans.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f05bead371d41ca5beef1f82e4c920c90e2eb9cd9fd537a5c91973bf9bd4eedb
User & Date: dan 2018-07-07 20:13:32
Context
2018-07-07
20:23
Fix the JSON extension so that it can be compiled separately from the amalgamation. check-in: 4b8cfe7b user: drh tags: trunk
20:13
Fix an LSM problem caused by using the same cursor for equality and range scans. check-in: f05bead3 user: dan tags: trunk
19:47
Add ALWAYS() macros on results of sqlite3_aggregate_context() calls in xInverse() implements, since they can never fail. check-in: fdef2a92 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm-test/lsmtest1.c.

   270    270     int *pRc                        /* OUT: Error code */
   271    271   ){
   272    272     int i;
   273    273     int iDot;
   274    274     int rc = LSM_OK;
   275    275     Datasource *pData;
   276    276     TestDb *pDb;
          277  +  int iToggle = 0;
   277    278   
   278    279     /* Start the test case, open a database and allocate the datasource. */
   279    280     pDb = testOpen(zSystem, 1, &rc);
   280    281     pData = testDatasourceNew(&p->defn);
   281    282   
   282    283     i = 0;
   283    284     iDot = 0;
   284    285     while( rc==LSM_OK && i<p->nRow ){
   285    286   
   286    287       /* Insert some data */
   287    288       testWriteDatasourceRange(pDb, pData, i, p->nVerify, &rc);
   288    289       i += p->nVerify;
   289    290   
          291  +    if( iToggle ) testBegin(pDb, 1, &rc);
   290    292       /* Check that the db content is correct. */
   291    293       testDbContents(pDb, pData, p->nRow, 0, i-1, p->nTest, p->bTestScan, &rc);
          294  +    if( iToggle ) testCommit(pDb, 0, &rc);
          295  +    iToggle = (iToggle+1)%2;
   292    296   
   293    297       if( bRecover ){
   294    298         testReopenRecover(&pDb, &rc);
   295    299       }else{
   296    300         testReopen(&pDb, &rc);
   297    301       }
   298    302   

Changes to ext/lsm1/lsm-test/lsmtest_tdb3.c.

   613    613   ){
   614    614     int rc;
   615    615     LsmDb *pDb = (LsmDb *)pTestDb;
   616    616     lsm_cursor *csr;
   617    617   
   618    618     if( pKey==0 ) return LSM_OK;
   619    619   
   620         -  rc = lsm_csr_open(pDb->db, &csr);
   621         -  if( rc!=LSM_OK ) return rc;
          620  +  if( pDb->pCsr==0 ){
          621  +    rc = lsm_csr_open(pDb->db, &csr);
          622  +    if( rc!=LSM_OK ) return rc;
          623  +  }else{
          624  +    csr = pDb->pCsr;
          625  +  }
   622    626   
   623    627     rc = lsm_csr_seek(csr, pKey, nKey, LSM_SEEK_EQ);
   624    628     if( rc==LSM_OK ){
   625    629       if( lsm_csr_valid(csr) ){
   626    630         const void *pVal; int nVal;
   627    631         rc = lsm_csr_value(csr, &pVal, &nVal);
   628    632         if( nVal>pDb->nBuf ){
................................................................................
   634    638         *ppVal = pDb->pBuf;
   635    639         *pnVal = nVal;
   636    640       }else{
   637    641         *ppVal = 0;
   638    642         *pnVal = -1;
   639    643       }
   640    644     }
   641         -  lsm_csr_close(csr);
          645  +  if( pDb->pCsr==0 ){
          646  +    lsm_csr_close(csr);
          647  +  }
   642    648     return rc;
   643    649   }
   644    650   
   645    651   static int test_lsm_scan(
   646    652     TestDb *pTestDb,
   647    653     void *pCtx,
   648    654     int bReverse,
   649    655     void *pFirst, int nFirst,
   650    656     void *pLast, int nLast,
   651    657     void (*xCallback)(void *, void *, int , void *, int)
   652    658   ){
   653    659     LsmDb *pDb = (LsmDb *)pTestDb;
   654    660     lsm_cursor *csr;
          661  +  lsm_cursor *csr2 = 0;
   655    662     int rc;
   656    663   
   657         -  rc = lsm_csr_open(pDb->db, &csr);
   658         -  if( rc!=LSM_OK ) return rc;
          664  +  if( pDb->pCsr==0 ){
          665  +    rc = lsm_csr_open(pDb->db, &csr);
          666  +    if( rc!=LSM_OK ) return rc;
          667  +  }else{
          668  +    rc = LSM_OK;
          669  +    csr = pDb->pCsr;
          670  +  }
   659    671   
   660    672     if( bReverse ){
   661    673       if( pLast ){
   662    674         rc = lsm_csr_seek(csr, pLast, nLast, LSM_SEEK_LE);
   663    675       }else{
   664    676         rc = lsm_csr_last(csr);
   665    677       }
................................................................................
   692    704       if( bReverse ){
   693    705         rc = lsm_csr_prev(csr);
   694    706       }else{
   695    707         rc = lsm_csr_next(csr);
   696    708       }
   697    709     }
   698    710   
   699         -  lsm_csr_close(csr);
          711  +  if( pDb->pCsr==0 ){
          712  +    lsm_csr_close(csr);
          713  +  }
   700    714     return rc;
   701    715   }
   702    716   
   703    717   static int test_lsm_begin(TestDb *pTestDb, int iLevel){
   704    718     int rc = LSM_OK;
   705    719     LsmDb *pDb = (LsmDb *)pTestDb;
   706    720   
................................................................................
   757    771   
   758    772   #define TEST_NO_RECOVERY -1
   759    773   #define TEST_COMPRESSION -3
   760    774   
   761    775   #define TEST_MT_MODE     -2
   762    776   #define TEST_MT_MIN_CKPT -4
   763    777   #define TEST_MT_MAX_CKPT -5
          778  +
   764    779   
   765    780   int test_lsm_config_str(
   766    781     LsmDb *pLsm,
   767    782     lsm_db *db, 
   768    783     int bWorker,
   769    784     const char *zStr,
   770    785     int *pnThread

Changes to ext/lsm1/lsm_sorted.c.

  2864   2864   }
  2865   2865   
  2866   2866   
  2867   2867   static int multiCursorEnd(MultiCursor *pCsr, int bLast){
  2868   2868     int rc = LSM_OK;
  2869   2869     int i;
  2870   2870   
  2871         -  pCsr->flags &= ~(CURSOR_NEXT_OK | CURSOR_PREV_OK);
         2871  +  pCsr->flags &= ~(CURSOR_NEXT_OK | CURSOR_PREV_OK | CURSOR_SEEK_EQ);
  2872   2872     pCsr->flags |= (bLast ? CURSOR_PREV_OK : CURSOR_NEXT_OK);
  2873   2873     pCsr->iFree = 0;
  2874   2874   
  2875   2875     /* Position the two in-memory tree cursors */
  2876   2876     for(i=0; rc==LSM_OK && i<2; i++){
  2877   2877       if( pCsr->apTreeCsr[i] ){
  2878   2878         rc = lsmTreeCursorEnd(pCsr->apTreeCsr[i], bLast);