/ Check-in [3d0e00c7]
Login

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

Overview
Comment:Proposed fix for ticket [a7b7803e8d1e8699cd8a].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-a7b7803e
Files: files | file ages | folders
SHA1:3d0e00c731c39af91bad74c6d74853375bac356e
User & Date: drh 2012-12-19 15:53:51
Context
2012-12-19
16:25
Additional test cases involving the use of a result column specified by its "AS" name as a logical term of the WHERE clause. Ticket [a7b7803e8d1e8699cd]. check-in: d7cc364e user: drh tags: tkt-a7b7803e
15:53
Proposed fix for ticket [a7b7803e8d1e8699cd8a]. check-in: 3d0e00c7 user: drh tags: tkt-a7b7803e
2012-12-18
19:36
Optimize the degenerate case of a FROM clause table name enclosed all by itself inside parentheses. Generate code as if the parentheses did not exist, rather than the old behavior of manifesting the parenthesized table into a transient table. Also, tag every FROM-clause SELECT subquery that is generated by a parenthesized FROM-clause expression using the SF_NestedFrom flag. The new SF_NestedFrom flag is not yet used for anything. check-in: 7fecced4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

   399    399       memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);
   400    400       if( pOld!=pWC->aStatic ){
   401    401         sqlite3DbFree(db, pOld);
   402    402       }
   403    403       pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
   404    404     }
   405    405     pTerm = &pWC->a[idx = pWC->nTerm++];
   406         -  pTerm->pExpr = p;
          406  +  pTerm->pExpr = sqlite3ExprSkipCollate(p);
   407    407     pTerm->wtFlags = wtFlags;
   408    408     pTerm->pWC = pWC;
   409    409     pTerm->iParent = -1;
   410    410     return idx;
   411    411   }
   412    412   
   413    413   /*
................................................................................
  1184   1184     sqlite3 *db = pParse->db;        /* Database connection */
  1185   1185   
  1186   1186     if( db->mallocFailed ){
  1187   1187       return;
  1188   1188     }
  1189   1189     pTerm = &pWC->a[idxTerm];
  1190   1190     pMaskSet = pWC->pMaskSet;
  1191         -  pExpr = sqlite3ExprSkipCollate(pTerm->pExpr);
         1191  +  pExpr = pTerm->pExpr;
         1192  +  assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
  1192   1193     prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft);
  1193   1194     op = pExpr->op;
  1194   1195     if( op==TK_IN ){
  1195   1196       assert( pExpr->pRight==0 );
  1196   1197       if( ExprHasProperty(pExpr, EP_xIsSelect) ){
  1197   1198         pTerm->prereqRight = exprSelectTableUsage(pMaskSet, pExpr->x.pSelect);
  1198   1199       }else{

Added test/tkt-a7b7803e.test.

            1  +# 2012 December 19
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library. Specifically,
           12  +# it tests that ticket [a7b7803e8d1e8699cd8a460a38133b98892d2e17] has
           13  +# been fixed.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +source $testdir/lock_common.tcl
           19  +source $testdir/malloc_common.tcl
           20  +
           21  +do_test tkt-a7b7803e.1 {
           22  +  db eval {
           23  +    CREATE TABLE t1(a);
           24  +    SELECT (t1.a==0) AS x
           25  +      FROM t1
           26  +     WHERE a=0 OR x;
           27  +  }
           28  +} {}
           29  +finish_test