/ Check-in [b6f2a7f9]
Login

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

Overview
Comment:Always clear the temporary register cache after coding a subroutine.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b6f2a7f9cdb547c925f08306df82519e41a7a0dd2cabd9861a48917bb6eef845
User & Date: drh 2019-09-18 20:34:54
Context
2019-09-19
13:51
Fix an assert() in fts3 that could fail when accessing a corrupt database. check-in: 601ce953 user: dan tags: trunk
2019-09-18
20:34
Always clear the temporary register cache after coding a subroutine. check-in: b6f2a7f9 user: drh tags: trunk
17:22
Add extra tests for the handling of corrupt records in fts3. check-in: 40e29a47 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  2863   2863       sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
  2864   2864     }
  2865   2865     if( addrOnce ){
  2866   2866       sqlite3VdbeJumpHere(v, addrOnce);
  2867   2867       /* Subroutine return */
  2868   2868       sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
  2869   2869       sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
         2870  +    sqlite3ClearTempRegCache(pParse);
  2870   2871     }
  2871   2872   }
  2872   2873   #endif /* SQLITE_OMIT_SUBQUERY */
  2873   2874   
  2874   2875   /*
  2875   2876   ** Generate code for scalar subqueries used as a subquery expression
  2876   2877   ** or EXISTS operator:
................................................................................
  2973   2974     ExprSetVVAProperty(pExpr, EP_NoReduce);
  2974   2975     if( addrOnce ){
  2975   2976       sqlite3VdbeJumpHere(v, addrOnce);
  2976   2977   
  2977   2978       /* Subroutine return */
  2978   2979       sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
  2979   2980       sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
         2981  +    sqlite3ClearTempRegCache(pParse);
  2980   2982     }
  2981   2983   
  2982   2984     return rReg;
  2983   2985   }
  2984   2986   #endif /* SQLITE_OMIT_SUBQUERY */
  2985   2987   
  2986   2988   #ifndef SQLITE_OMIT_SUBQUERY
................................................................................
  5604   5606       pParse->nRangeReg = nReg;
  5605   5607       pParse->iRangeReg = iReg;
  5606   5608     }
  5607   5609   }
  5608   5610   
  5609   5611   /*
  5610   5612   ** Mark all temporary registers as being unavailable for reuse.
         5613  +**
         5614  +** Always invoke this procedure after coding a subroutine or co-routine
         5615  +** that might be invoked from other parts of the code, to ensure that
         5616  +** the sub/co-routine does not use registers in common with the code that
         5617  +** invokes the sub/co-routine.
  5611   5618   */
  5612   5619   void sqlite3ClearTempRegCache(Parse *pParse){
  5613   5620     pParse->nTempReg = 0;
  5614   5621     pParse->nRangeReg = 0;
  5615   5622   }
  5616   5623   
  5617   5624   /*

Changes to test/tkt-3a77c9714e.test.

     1         -# 2011 December 06
            1  +# 2011-12-06
     2      2   #
     3      3   # The author disclaims copyright to this source code.  In place of
     4      4   # a legal notice, here is a blessing:
     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
................................................................................
    64     64           SELECT SrcWord, B.Id as BeginningId, B.Title || E.Title As Connected
    65     65           FROM Beginnings B LEFT JOIN Endings E ON B.EndingId=E.EndingId
    66     66           WHERE Connected=SrcWord LIMIT 1
    67     67         )
    68     68       )
    69     69   } {FACTORING FACTOR SWIMMING SWIMM} 
    70     70   
           71  +# Similar problem discovered by dbsqlfuzz on 2019-09-18
           72  +#
           73  +do_execsql_test 3.0 {
           74  +  DROP TABLE IF EXISTS t1;
           75  +  CREATE TABLE t1(i INT PRIMARY KEY, a, b);
           76  +  INSERT INTO t1 VALUES(NULL,'one','i');
           77  +  CREATE INDEX i1a ON t1(a);
           78  +  CREATE INDEX i1b ON t1(b);
           79  +  SELECT (SELECT 1
           80  +            FROM (SELECT 1 FROM t1 WHERE a=1 OR b='i')
           81  +           WHERE a='o'
           82  +              OR b IN (SELECT a=('b' IN (SELECT 'a'))))
           83  +    FROM t1;
           84  +} {{}}
    71     85   
    72     86   finish_test