SQLite4
Check-in [6998cd99b8]
Not logged in

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

Overview
Comment:Fix a problem with iterating in reverse order through the merge-tree.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6998cd99b8be1039dcbe970ebfede37c3ab06ffa
User & Date: dan 2014-01-25 15:14:14
Context
2014-01-26
17:13
Fix a bug in merge-tree rollback operations. check-in: 60c8db5553 user: dan tags: trunk
2014-01-25
15:14
Fix a problem with iterating in reverse order through the merge-tree. check-in: 6998cd99b8 user: dan tags: trunk
2014-01-23
19:00
And another bug in merging. check-in: 1b27f1ca1e user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/bt_main.c.

1565
1566
1567
1568
1569
1570
1571

















1572
1573
1574
1575
1576
1577
1578
      rc = btCsrData(&pSub->mcsr, 0, 4, &pV, &nV);
    }
    if( rc==SQLITE4_OK ){
      pSub->csr.iRoot = sqlite4BtGetU32((const u8*)pV);
      rc = btCsrEnd(&pSub->csr, !bNext);
    }
  }


















  return rc;
}

/*
** Advance the cursor. The direction (xPrev or xNext) is implied by the
** cursor itself - as fast-insert cursors may only be advanced in one







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
      rc = btCsrData(&pSub->mcsr, 0, 4, &pV, &nV);
    }
    if( rc==SQLITE4_OK ){
      pSub->csr.iRoot = sqlite4BtGetU32((const u8*)pV);
      rc = btCsrEnd(&pSub->csr, !bNext);
    }
  }
  
  if( bNext==0 ){
    /* If this is an xPrev() operation, check that the cursor has not moved
    ** into a part of the sub-tree that has been gobbled up by an ongoing
    ** merge.  */
    const void *pMin; int nMin;
    const void *pKey; int nKey;

    if( rc==SQLITE4_OK ) rc = btCsrKey(&pSub->mcsr, &pMin, &nMin);
    if( rc==SQLITE4_OK ) rc = btCsrKey(&pSub->csr, &pKey, &nKey);

    if( rc==SQLITE4_OK && btKeyCompare((u8*)pMin+8, nMin-8, pKey, nKey)>0 ){
      rc = SQLITE4_NOTFOUND;
      btCsrReset(&pSub->mcsr, 0);
      btCsrReset(&pSub->csr, 0);
    }
  }

  return rc;
}

/*
** Advance the cursor. The direction (xPrev or xNext) is implied by the
** cursor itself - as fast-insert cursors may only be advanced in one