/ Check-in [941d8142]
Login

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

Overview
Comment:Ensure that the expression rewriter inside the query flattener decends into the substructure of the TK_IF_NULL_ROW operator. This is a continuation of the fix for ticket [cad1ab4cb7b0fc344].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 941d8142b7c9a96ff143d1add3c86cf42d61fd08e532d400dac555f23eadbcfb
User & Date: drh 2017-05-23 12:36:13
Context
2017-05-23
15:21
Disable the LEFT JOIN flattening optimization for aggregate queries, as it does not currently work. Further fix for ticket [cad1ab4cb7b0fc344]. check-in: 44b21e35 user: drh tags: trunk
12:44
Ensure that the expression rewriter inside the query flattener decends into the substructure of the TK_IF_NULL_ROW operator. This is a continuation of the fix for ticket [cad1ab4cb7b0fc344]. check-in: 28d2902d user: drh tags: branch-3.19
12:36
Ensure that the expression rewriter inside the query flattener decends into the substructure of the TK_IF_NULL_ROW operator. This is a continuation of the fix for ticket [cad1ab4cb7b0fc344]. check-in: 941d8142 user: drh tags: trunk
01:21
When flattening a query, make sure iTable attribute of TK_IF_NULL_ROW operators (that result from a prior flattening of a LEFT JOIN) are updated correctly. Fix for ticket [cad1ab4cb7b0fc344]. check-in: 92c17850 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

3209
3210
3211
3212
3213
3214
3215

3216
3217
3218

3219
3220
3221
3222
3223
3224
3225
          pNew->iRightJoinTable = pExpr->iRightJoinTable;
          pNew->flags |= EP_FromJoin;
        }
        sqlite3ExprDelete(db, pExpr);
        pExpr = pNew;
      }
    }

  }else if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
    pExpr->iTable = pSubst->iNewTable;
  }else{

    pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
    pExpr->pRight = substExpr(pSubst, pExpr->pRight);
    if( ExprHasProperty(pExpr, EP_xIsSelect) ){
      substSelect(pSubst, pExpr->x.pSelect, 1);
    }else{
      substExprList(pSubst, pExpr->x.pList);
    }







>
|
|
<
>







3209
3210
3211
3212
3213
3214
3215
3216
3217
3218

3219
3220
3221
3222
3223
3224
3225
3226
          pNew->iRightJoinTable = pExpr->iRightJoinTable;
          pNew->flags |= EP_FromJoin;
        }
        sqlite3ExprDelete(db, pExpr);
        pExpr = pNew;
      }
    }
  }else{
    if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
      pExpr->iTable = pSubst->iNewTable;

    }
    pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
    pExpr->pRight = substExpr(pSubst, pExpr->pRight);
    if( ExprHasProperty(pExpr, EP_xIsSelect) ){
      substSelect(pSubst, pExpr->x.pSelect, 1);
    }else{
      substExprList(pSubst, pExpr->x.pList);
    }

Changes to test/join.test.

722
723
724
725
726
727
728





729
730
} {1 1 1}
do_execsql_test join-14.2 {
  SELECT *
  FROM (SELECT 1 a) AS x
    LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT * FROM (SELECT 1)))) AS y
    JOIN (SELECT * FROM (SELECT 9)) AS z;
} {1 1 1 9}






finish_test







>
>
>
>
>


722
723
724
725
726
727
728
729
730
731
732
733
734
735
} {1 1 1}
do_execsql_test join-14.2 {
  SELECT *
  FROM (SELECT 1 a) AS x
    LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT * FROM (SELECT 1)))) AS y
    JOIN (SELECT * FROM (SELECT 9)) AS z;
} {1 1 1 9}
do_execsql_test join-14.3 {
  SELECT *
  FROM (SELECT 111)
  LEFT JOIN (SELECT cc+222, * FROM (SELECT * FROM (SELECT 333 cc)));
} {111 555 333}

finish_test