/ Check-in [96be3f7b]
Login

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

Overview
Comment:Fix a problem with SQLITE_OMIT_TRACE that was introduced by the recent OP_Once change.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 96be3f7b59b3ed4703b907e29db629df34b2b56f
User & Date: drh 2011-09-16 22:10:57
Context
2011-09-17
15:34
Make sure the file structure is zeroed prior to calling the VFS to open a file. check-in: 29c4d0dd user: mistachkin tags: trunk
2011-09-16
22:10
Fix a problem with SQLITE_OMIT_TRACE that was introduced by the recent OP_Once change. check-in: 96be3f7b user: drh tags: trunk
20:43
Fix #if's in winSync to avoid compiler warnings about unused local variables. Also, update version numbers in the MSVC makefile. check-in: 2e66e414 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  1570   1570   #ifndef SQLITE_OMIT_SUBQUERY
  1571   1571   int sqlite3CodeSubselect(
  1572   1572     Parse *pParse,          /* Parsing context */
  1573   1573     Expr *pExpr,            /* The IN, SELECT, or EXISTS operator */
  1574   1574     int rMayHaveNull,       /* Register that records whether NULLs exist in RHS */
  1575   1575     int isRowid             /* If true, LHS of IN operator is a rowid */
  1576   1576   ){
  1577         -  int testAddr = 0;                       /* One-time test address */
         1577  +  int testAddr = -1;                      /* One-time test address */
  1578   1578     int rReg = 0;                           /* Register storing resulting */
  1579   1579     Vdbe *v = sqlite3GetVdbe(pParse);
  1580   1580     if( NEVER(v==0) ) return 0;
  1581         -  assert( sqlite3VdbeCurrentAddr(v)>0 );
  1582   1581     sqlite3ExprCachePush(pParse);
  1583   1582   
  1584   1583     /* This code must be run in its entirety every time it is encountered
  1585   1584     ** if any of the following is true:
  1586   1585     **
  1587   1586     **    *  The right-hand side is a correlated subquery
  1588   1587     **    *  The right-hand side is an expression list containing variables
................................................................................
  1590   1589     **
  1591   1590     ** If all of the above are false, then we can run this code just once
  1592   1591     ** save the results, and reuse the same result on subsequent invocations.
  1593   1592     */
  1594   1593     if( !ExprHasAnyProperty(pExpr, EP_VarSelect) && !pParse->pTriggerTab ){
  1595   1594       int mem = ++pParse->nMem;
  1596   1595       testAddr = sqlite3VdbeAddOp1(v, OP_Once, mem);
  1597         -    assert( testAddr>0 || pParse->db->mallocFailed );
  1598   1596     }
  1599   1597   
  1600   1598   #ifndef SQLITE_OMIT_EXPLAIN
  1601   1599     if( pParse->explain==2 ){
  1602   1600       char *zMsg = sqlite3MPrintf(
  1603         -        pParse->db, "EXECUTE %s%s SUBQUERY %d", testAddr?"":"CORRELATED ",
         1601  +        pParse->db, "EXECUTE %s%s SUBQUERY %d", testAddr>=0?"":"CORRELATED ",
  1604   1602           pExpr->op==TK_IN?"LIST":"SCALAR", pParse->iNextSelectId
  1605   1603       );
  1606   1604       sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
  1607   1605     }
  1608   1606   #endif
  1609   1607   
  1610   1608     switch( pExpr->op ){
................................................................................
  1688   1686             int iValToIns;
  1689   1687   
  1690   1688             /* If the expression is not constant then we will need to
  1691   1689             ** disable the test that was generated above that makes sure
  1692   1690             ** this code only executes once.  Because for a non-constant
  1693   1691             ** expression we need to rerun this code each time.
  1694   1692             */
  1695         -          if( testAddr && !sqlite3ExprIsConstant(pE2) ){
         1693  +          if( testAddr>=0 && !sqlite3ExprIsConstant(pE2) ){
  1696   1694               sqlite3VdbeChangeToNoop(v, testAddr);
  1697         -            testAddr = 0;
         1695  +            testAddr = -1;
  1698   1696             }
  1699   1697   
  1700   1698             /* Evaluate the expression and insert it into the temp table */
  1701   1699             if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){
  1702   1700               sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);
  1703   1701             }else{
  1704   1702               r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
................................................................................
  1759   1757         }
  1760   1758         rReg = dest.iParm;
  1761   1759         ExprSetIrreducible(pExpr);
  1762   1760         break;
  1763   1761       }
  1764   1762     }
  1765   1763   
  1766         -  if( testAddr ){
         1764  +  if( testAddr>=0 ){
  1767   1765       sqlite3VdbeJumpHere(v, testAddr);
  1768   1766     }
  1769   1767     sqlite3ExprCachePop(pParse, 1);
  1770   1768   
  1771   1769     return rReg;
  1772   1770   }
  1773   1771   #endif /* SQLITE_OMIT_SUBQUERY */