/ Check-in [bdd8ce58]
Login

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

Overview
Comment:Fix for bug #6: Correctly handle functions in the WHERE clause of a join. (CVS 513)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bdd8ce584e16fe288a7e8386f897cb36a60e8431
User & Date: drh 2002-04-02 01:58:58
Context
2002-04-02
02:00
Version 2.4.5 (CVS 514) check-in: b18a7b77 user: drh tags: trunk
01:58
Fix for bug #6: Correctly handle functions in the WHERE clause of a join. (CVS 513) check-in: bdd8ce58 user: drh tags: trunk
01:44
Fix for bug #7: Correctly display the P3 operand in a VDBE trace when the operand is really a pointer to a structure. (CVS 512) check-in: 734dde76 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  Also found here are subroutines
    14     14   ** to generate VDBE code to evaluate expressions.
    15     15   **
    16         -** $Id: where.c,v 1.38 2002/03/02 17:04:09 drh Exp $
           16  +** $Id: where.c,v 1.39 2002/04/02 01:58:58 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   
    20     20   /*
    21     21   ** The query generator uses an array of instances of this structure to
    22     22   ** help it analyze the subexpressions of the WHERE clause.  Each WHERE
    23     23   ** clause subexpression is separated from the others by an AND operator.
................................................................................
    85     85       return 1<< (p->iTable - base);
    86     86     }
    87     87     if( p->pRight ){
    88     88       mask = exprTableUsage(base, p->pRight);
    89     89     }
    90     90     if( p->pLeft ){
    91     91       mask |= exprTableUsage(base, p->pLeft);
           92  +  }
           93  +  if( p->pList ){
           94  +    int i;
           95  +    for(i=0; i<p->pList->nExpr; i++){
           96  +      mask |= exprTableUsage(base, p->pList->a[i].pExpr);
           97  +    }
    92     98     }
    93     99     return mask;
    94    100   }
    95    101   
    96    102   /*
    97    103   ** Return TRUE if the given operator is one of the operators that is
    98    104   ** allowed for an indexable WHERE clause.  The allowed operators are

Changes to test/select2.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the SELECT statement.
    13     13   #
    14         -# $Id: select2.test,v 1.16 2001/11/23 00:24:13 drh Exp $
           14  +# $Id: select2.test,v 1.17 2002/04/02 01:58:58 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a table with some data
    20     20   #
    21     21   execsql {CREATE TABLE tbl1(f1 int, f2 int)}
................................................................................
   108    108   #
   109    109   do_test select2-3.3 {
   110    110     execsql {DROP INDEX idx1}
   111    111     set sqlite_search_count 0
   112    112     execsql {SELECT f1 FROM tbl2 WHERE f2==2000}
   113    113     set sqlite_search_count
   114    114   } {29999}
          115  +
          116  +# Make sure we can optimize functions in the WHERE clause that
          117  +# use fields from two or more different table.  (Bug #6)
          118  +#
          119  +do_test select2-4.1 {
          120  +  execsql {
          121  +    CREATE TABLE aa(a);
          122  +    CREATE TABLE bb(b);
          123  +    INSERT INTO aa VALUES(1);
          124  +    INSERT INTO aa VALUES(3);
          125  +    INSERT INTO bb VALUES(2);
          126  +    INSERT INTO bb VALUES(4);
          127  +    SELECT * FROM aa, bb WHERE max(a,b)>2;
          128  +  }
          129  +} {1 4 3 2 3 4}
   115    130   
   116    131   finish_test

Changes to www/changes.tcl.

    21     21   
    22     22   
    23     23   proc chng {date desc} {
    24     24     puts "<DT><B>$date</B></DT>"
    25     25     puts "<DD><P><UL>$desc</UL></P></DD>"
    26     26   }
    27     27   
    28         -chng {2002 Mar 31 (2.4.5)} {
           28  +chng {2002 Apr 01 (2.4.5)} {
           29  +<li>Bug fix: Correctly handle functions that appear in the WHERE clause
           30  +    of a SELECT.</li>
           31  +<li>When the PRAGMA vdbe_trace=ON is set, correctly print the P3 operand
           32  +    value when it is a pointer to a structure rather than a pointer to
           33  +    a string.</li>
    29     34   <li>When inserting an explicit NULL into an INTEGER PRIMARY KEY, convert
    30     35       the NULL value into a unique key automatically.</li>
    31     36   }
    32     37   
    33     38   chng {2002 Mar 24 (2.4.4)} {
    34     39   <li>Allow "VIEW" to be a column name</li>
    35     40   <li>Added support for CASE expressions (patch from Dan Kennedy)</li>