SQLite

Check-in [e5c30f227b]
Login

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

Overview
Comment:Fix a problem in internal function sqlite3OpenTableAndIndices causing an operand of an unrelated VM instruction to be overwritten. Fix for [ef360601].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | branch-3.14
Files: files | file ages | folders
SHA1: e5c30f227b3f6cae18cc85655149636372592bf8
User & Date: drh 2016-09-07 11:27:05.082
Context
2016-09-07
12:08
The ORDER BY LIMIT optimization is not valid unless the inner-most IN operator loop is actually used by the query plan. Fix for ticket [0c4df46116e90f92]. (check-in: b4f8be1f32 user: drh tags: branch-3.14)
11:27
Fix a problem in internal function sqlite3OpenTableAndIndices causing an operand of an unrelated VM instruction to be overwritten. Fix for [ef360601]. (check-in: e5c30f227b user: drh tags: branch-3.14)
2016-08-26
12:00
Fix a problem in internal function sqlite3OpenTableAndIndices causing an operand of an unrelated VM instruction to be overwritten. Fix for [ef360601]. (check-in: 7090147903 user: dan tags: trunk)
2016-08-11
18:53
Version 3.14.1 (check-in: a12d805977 user: drh tags: release, branch-3.14, version-3.14.1)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/insert.c.
1773
1774
1775
1776
1777
1778
1779




1780
1781
1782
1783
1784
1785
1786
1787
1788

1789
1790
1791
1792
1793
1794
1795
  }else{
    sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName);
  }
  if( piIdxCur ) *piIdxCur = iBase;
  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
    int iIdxCur = iBase++;
    assert( pIdx->pSchema==pTab->pSchema );




    if( aToOpen==0 || aToOpen[i+1] ){
      sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
      VdbeComment((v, "%s", pIdx->zName));
    }
    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
      if( piDataCur ) *piDataCur = iIdxCur;
    }else{
      sqlite3VdbeChangeP5(v, p5);

    }
  }
  if( iBase>pParse->nTab ) pParse->nTab = iBase;
  return i;
}









>
>
>
>



<
<
<
<
<

>







1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786





1787
1788
1789
1790
1791
1792
1793
1794
1795
  }else{
    sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName);
  }
  if( piIdxCur ) *piIdxCur = iBase;
  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
    int iIdxCur = iBase++;
    assert( pIdx->pSchema==pTab->pSchema );
    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
      if( piDataCur ) *piDataCur = iIdxCur;
      p5 = 0;
    }
    if( aToOpen==0 || aToOpen[i+1] ){
      sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);





      sqlite3VdbeChangeP5(v, p5);
      VdbeComment((v, "%s", pIdx->zName));
    }
  }
  if( iBase>pParse->nTab ) pParse->nTab = iBase;
  return i;
}


Changes to test/delete.test.
384
385
386
387
388
389
390














391
392
393
  set res [list]
  db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {
    if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 3 } }
    lappend res $r $c $d
  }
  set res
} {1 a b 1 c d 2 a b 2 c d}
















finish_test







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



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
  set res [list]
  db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {
    if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 3 } }
    lappend res $r $c $d
  }
  set res
} {1 a b 1 c d 2 a b 2 c d}

do_execsql_test delete-10.0 {
  CREATE TABLE t1(a INT UNIQUE, b INT);
  INSERT INTO t1(a,b) VALUES('1','2');
  SELECT * FROM t1 WHERE a='1' AND b='2';
} {1 2}

do_execsql_test delete-10.1 {
  DELETE FROM t1 WHERE a='1' AND b='2';
}

do_execsql_test delete-10.2 {
  SELECT * FROM t1 WHERE a='1' AND b='2';
}


finish_test