SQLite

Check-in [a33179596f]
Login

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

Overview
Comment:Remove an unnecessary branch.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | having-where-optimization
Files: files | file ages | folders
SHA3-256: a33179596f534067a58d68b77160f11ab13272b29f912d7cbe15ea00bbf03ade
User & Date: drh 2017-05-01 19:53:12.478
Context
2017-05-02
16:46
Additional comments on the sqlite3ExprIsConstantOrGroupBy() routine. No code changes. (Closed-Leaf check-in: 8424492eac user: drh tags: having-where-optimization)
2017-05-01
19:53
Remove an unnecessary branch. (check-in: a33179596f user: drh tags: having-where-optimization)
14:09
Add extra tests for the optimization on this branch. (check-in: 4921cd9520 user: dan tags: having-where-optimization)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
    struct HavingToWhereCtx *p = pWalker->u.pHavingCtx;
    if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, p->pGroupBy) ){
      sqlite3 *db = pWalker->pParse->db;
      Expr *pNew = sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0);
      if( pNew ){
        Expr *pWhere = *(p->ppWhere);
        SWAP(Expr, *pNew, *pExpr);
        if( pWhere ){
          pNew = sqlite3ExprAnd(db, pWhere, pNew);
        }
        *(p->ppWhere) = pNew;
      }
    }
    return WRC_Prune;
  }
  return WRC_Continue;
}







<
|
<







4903
4904
4905
4906
4907
4908
4909

4910

4911
4912
4913
4914
4915
4916
4917
    struct HavingToWhereCtx *p = pWalker->u.pHavingCtx;
    if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, p->pGroupBy) ){
      sqlite3 *db = pWalker->pParse->db;
      Expr *pNew = sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0);
      if( pNew ){
        Expr *pWhere = *(p->ppWhere);
        SWAP(Expr, *pNew, *pExpr);

        pNew = sqlite3ExprAnd(db, pWhere, pNew);

        *(p->ppWhere) = pNew;
      }
    }
    return WRC_Prune;
  }
  return WRC_Continue;
}