/ Check-in [1c1b0862]
Login

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

Overview
Comment:When building an ephemeral table of integers, do not assume that the table does not already contain N if the insert cursor points to N-1. Fix for ticket [61fe9745].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1c1b0862236f564283be08338790d6494e705f1198547a59499e3f8c07f2cd99
User & Date: dan 2017-04-24 14:16:55
References
2017-04-24
14:57 Closed ticket [61fe9745]: Duplicate result using an IN operator in the WHERE clause plus 6 other changes artifact: 3998d56c user: dan
Context
2017-06-17
00:39
When building an ephemeral table of integers, do not assume that the table does not already contain N if the insert cursor points to N-1. Fix for ticket [61fe9745]. Also increase the version number to 3.18.2. This is the release candidate. check-in: e1b71029 user: drh tags: branch-3.18
2017-04-26
04:32
Fix a subtle bug in Lemon discovered and reported on the mailing list by Kelvin Sherlock, who also suggested the correct fix. check-in: 304689f8 user: drh tags: trunk
2017-04-24
16:14
Bring in all the latest enhancements from trunk. check-in: 031feebc user: drh tags: apple-osx
14:16
When building an ephemeral table of integers, do not assume that the table does not already contain N if the insert cursor points to N-1. Fix for ticket [61fe9745]. check-in: 1c1b0862 user: dan tags: trunk
2017-04-22
00:20
Fix an assertion fault found by OSSFuzz. check-in: e39769f4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  8120   8120               ((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) );
  8121   8121   
  8122   8122       /* If the cursor is currently on the last row and we are appending a
  8123   8123       ** new row onto the end, set the "loc" to avoid an unnecessary
  8124   8124       ** btreeMoveto() call */
  8125   8125       if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){
  8126   8126         loc = 0;
  8127         -    }else if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0
  8128         -               && pCur->info.nKey==pX->nKey-1 ){
  8129         -      loc = -1;
  8130   8127       }else if( loc==0 ){
  8131   8128         rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
  8132   8129         if( rc ) return rc;
  8133   8130       }
  8134   8131     }else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){
  8135   8132       if( pX->nMem ){
  8136   8133         UnpackedRecord r;

Changes to test/in5.test.

   232    232   do_execsql_test 8.3 {
   233    233     INSERT INTO n1 VALUES(1, NULL), (2, NULL), (3, NULL);
   234    234     SELECT count(*) FROM n1 WHERE a IN (1, 2, 3)
   235    235   } 3
   236    236   do_execsql_test 8.4 {
   237    237     SELECT count(*) FROM n1 WHERE a IN (SELECT +a FROM n1)
   238    238   } 3
          239  +
          240  +#-------------------------------------------------------------------------
          241  +# Test that ticket 61fe97454c is fixed.
          242  +#
          243  +do_execsql_test 9.0 {
          244  +  CREATE TABLE t9(a INTEGER PRIMARY KEY);
          245  +  INSERT INTO t9 VALUES (44), (45);
          246  +}
          247  +do_execsql_test 9.1 {
          248  +  SELECT * FROM t9 WHERE a IN (44, 45, 44, 45)
          249  +} {44 45}
          250  +
   239    251   
   240    252   finish_test