/ Check-in [9843c0dd]
Login

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

Overview
Comment:Respect collation sequences in views. Ticket #1088. (CVS 2291)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9843c0dd795ceda3c260986f95b101a0cbc7cf64
User & Date: danielk1977 2005-01-30 11:11:44
Context
2005-01-30
22:10
User-contributed chagnes to tclinstaller so that it supports DESTDIR. (CVS 2292) check-in: ab8dbcf5 user: drh tags: trunk
11:11
Respect collation sequences in views. Ticket #1088. (CVS 2291) check-in: 9843c0dd user: danielk1977 tags: trunk
09:17
Have the optimization introduced in (2170) deal with OP_NullRow as well as OP_Column and OP_Recno. Fix for #1086. (CVS 2290) check-in: 356d31e0 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.235 2005/01/29 08:32:45 danielk1977 Exp $
           15  +** $Id: select.c,v 1.236 2005/01/30 11:11:44 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Allocate a new Select structure and return a pointer to that
    22     22   ** structure.
................................................................................
   852    852     Table *pTab;
   853    853     int i, j;
   854    854     ExprList *pEList;
   855    855     Column *aCol, *pCol;
   856    856   
   857    857     if( prepSelectStmt(pParse, pSelect) ){
   858    858       return 0;
          859  +  }
          860  +  if( sqlite3SelectResolve(pParse, pSelect, 0) ){
          861  +    return 0;
   859    862     }
   860    863     pTab = sqliteMalloc( sizeof(Table) );
   861    864     if( pTab==0 ){
   862    865       return 0;
   863    866     }
   864    867     pTab->zName = zTabName ? sqliteStrDup(zTabName) : 0;
   865    868     pEList = pSelect->pEList;
................................................................................
   985    988   #ifndef SQLITE_OMIT_SUBQUERY
   986    989         /* A sub-query in the FROM clause of a SELECT */
   987    990         assert( pFrom->pSelect!=0 );
   988    991         if( pFrom->zAlias==0 ){
   989    992           pFrom->zAlias =
   990    993             sqlite3MPrintf("sqlite_subquery_%p_", (void*)pFrom->pSelect);
   991    994         }
   992         -      sqlite3SelectResolve(pParse, pFrom->pSelect, 0);
   993    995         pFrom->pTab = pTab = 
   994    996           sqlite3ResultSetOfSelect(pParse, pFrom->zAlias, pFrom->pSelect);
   995    997         if( pTab==0 ){
   996    998           return 1;
   997    999         }
   998   1000         /* The isTransient flag indicates that the Table structure has been
   999   1001         ** dynamically allocated and may be freed at any time.  In other words,

Changes to test/subquery.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 script is testing correlated subqueries
    13     13   #
    14         -# $Id: subquery.test,v 1.3 2005/01/29 08:32:47 danielk1977 Exp $
           14  +# $Id: subquery.test,v 1.4 2005/01/30 11:11:44 danielk1977 Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   ifcapable !subquery {
    21     21     finish_test
................................................................................
    75     75   do_test subquery-1.7 {
    76     76     execsql {
    77     77       SELECT a, x FROM t2, t1 WHERE t1.a = (SELECT x);
    78     78     }
    79     79   } {1 1 3 3 5 5 7 7}
    80     80   
    81     81   # Try an aggregate in both the subquery and the parent query.
    82         -do_test subquery-1.6 {
           82  +do_test subquery-1.8 {
    83     83     execsql {
    84     84       SELECT count(*) FROM t1 WHERE a > (SELECT count(*) FROM t2);
    85     85     }
    86     86   } {2}
           87  +
           88  +# Test a correlated subquery disables the "only open the index" optimization.
           89  +do_test subquery-1.9.1 {
           90  +  execsql {
           91  +    SELECT (y*2)>b FROM t1, t2 WHERE a=x;
           92  +  }
           93  +} {0 1 1 1}
           94  +do_test subquery-1.9.2 {
           95  +  execsql {
           96  +    SELECT a FROM t1 WHERE (SELECT (y*2)>b FROM t2 WHERE a=x); 
           97  +  }
           98  +} {3 5 7}
    87     99   
    88    100   
    89    101   #------------------------------------------------------------------
    90    102   # The following test cases - subquery-2.* - are not logically
    91    103   # organized. They're here largely because they were failing during
    92    104   # one stage of development of sub-queries.
    93    105   #

Changes to test/view.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 VIEW statements.
    13     13   #
    14         -# $Id: view.test,v 1.23 2005/01/29 08:32:47 danielk1977 Exp $
           14  +# $Id: view.test,v 1.24 2005/01/30 11:11:44 danielk1977 Exp $
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
    17     17   
    18     18   # Omit this entire file if the library is not configured with views enabled.
    19     19   ifcapable !view {
    20     20     finish_test
    21     21     return
................................................................................
   414    414     }
   415    415   } {1}
   416    416   do_test view-10.2 {
   417    417     execsql {
   418    418       SELECT * FROM v_t3_b;
   419    419     }
   420    420   } {2}
          421  +
          422  +do_test view-11.1 {
          423  +  execsql {
          424  +    CREATE TABLE t4(a COLLATE NOCASE);
          425  +    INSERT INTO t4 VALUES('This');
          426  +    INSERT INTO t4 VALUES('this');
          427  +    INSERT INTO t4 VALUES('THIS');
          428  +    SELECT * FROM t4 WHERE a = 'THIS';
          429  +  }
          430  +} {This this THIS}
          431  +do_test view-11.2 {
          432  +  execsql {
          433  +    SELECT * FROM (SELECT * FROM t4) WHERE a = 'THIS';
          434  +  }
          435  +} {This this THIS}
          436  +do_test view-11.3 {
          437  +  execsql {
          438  +    CREATE VIEW v11 AS SELECT * FROM t4;
          439  +    SELECT * FROM v11 WHERE a = 'THIS';
          440  +  }
          441  +} {This this THIS}
   421    442   
   422    443   finish_test