/ Check-in [6b24d3fb]
Login

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

Overview
Comment:Prevent the use of subroutines to implement the RHS of IN operators within CHECK constraints.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | reuse-subqueries
Files: files | file ages | folders
SHA3-256: 6b24d3fb94e787d25e49501714780dfb0c0c99077102056aa68445f4808cdd57
User & Date: drh 2018-12-24 11:55:44
Context
2018-12-24
12:09
Do not generate subroutines for non-static SELECT and EXISTS expressions. Fix up some test cases to account for the minor changes in EXPLAIN QUERY PLAN output. check-in: 06de44ec user: drh tags: reuse-subqueries
11:55
Prevent the use of subroutines to implement the RHS of IN operators within CHECK constraints. check-in: 6b24d3fb user: drh tags: reuse-subqueries
02:34
Experimental code that tries to put the computation of subqueries inside a subroutine, and reuse that subroutine if the same subquery is evaluated more than once. Current code does not work for CHECK constraints. check-in: 6c44838a user: drh tags: reuse-subqueries
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  2681   2681     **    *  The right-hand side is a correlated subquery
  2682   2682     **    *  The right-hand side is an expression list containing variables
  2683   2683     **    *  We are inside a trigger
  2684   2684     **
  2685   2685     ** If all of the above are false, then we can compute the RHS just once
  2686   2686     ** and reuse it many names.
  2687   2687     */
  2688         -  if( !ExprHasProperty(pExpr, EP_VarSelect) ){
         2688  +  if( !ExprHasProperty(pExpr, EP_VarSelect) && pParse->iSelfTab==0 ){
  2689   2689       /* Reuse of the RHS is allowed */
  2690   2690       /* If this routine has already been coded, but the previous code
  2691   2691       ** might not have been invoked yet, so invoke it now as a subroutine. 
  2692   2692       */
  2693   2693       if( ExprHasProperty(pExpr, EP_Subrtn) ){
  2694   2694         sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
  2695   2695         sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,