SQLite

Check-in [6b24d3fb94]
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
Timelines: family | ancestors | descendants | both | reuse-subqueries
Files: files | file ages | folders
SHA3-256: 6b24d3fb94e787d25e49501714780dfb0c0c99077102056aa68445f4808cdd57
User & Date: drh 2018-12-24 11:55:44.935
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: 06de44ec9e user: drh tags: reuse-subqueries)
11:55
Prevent the use of subroutines to implement the RHS of IN operators within CHECK constraints. (check-in: 6b24d3fb94 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: 6c44838adb user: drh tags: reuse-subqueries)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
  **    *  The right-hand side is a correlated subquery
  **    *  The right-hand side is an expression list containing variables
  **    *  We are inside a trigger
  **
  ** If all of the above are false, then we can compute the RHS just once
  ** and reuse it many names.
  */
  if( !ExprHasProperty(pExpr, EP_VarSelect) ){
    /* Reuse of the RHS is allowed */
    /* If this routine has already been coded, but the previous code
    ** might not have been invoked yet, so invoke it now as a subroutine. 
    */
    if( ExprHasProperty(pExpr, EP_Subrtn) ){
      sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
      sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,







|







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