SQLite
View Ticket
Not logged in
Ticket UUID: a7b7803e8d1e8699cd8a460a38133b98892d2e17
Title: crash when filtering twice by same predicate using aliases
Status: Fixed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Code_Generator Resolution: Fixed
Last Modified: 2012-12-19 16:58:04
Version Found In: 3.7.15
User Comments:
nobody added on 2012-12-19 15:01:05: (text/x-fossil-wiki)
Try the following:
<pre>
 create table name (
   type integer,
   path text primary key);

 select (name.type = 0) as container from Name name where name.type = 0 or    container order by name.path
</pre>
---

The select statement crashes during query preparation.


[7b96115e81deab0aa0472839cf787ba3f2fc64a7]

<pre>
  char sqlite3ExprAffinity(Expr *pExpr){
    int op;
    pExpr = sqlite3ExprSkipCollate(pExpr);
    int op = pExpr->op;                               
    op = pExpr->op;
    ...
</pre>
last line crashes because sqlite3ExprSkipCollate returns null.

nobody added on 2012-12-19 15:13:42: (text/x-fossil-plain)
pExpr is already NULL from caller 'exprAnalyzeOrTerm' -> affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);

drh added on 2012-12-19 15:16:52: (text/x-fossil-wiki)
Bisecting shows that the bug was introduced by the refactoring of COLLATE at
check-in [8542e6180d4321d45b], just a few days prior to the release of
version 3.7.15, and needed to address bug [71e333e7d2e642afc96d2].  

So, we fixed one bug but in the process introduced another....