/ Check-in [b2784cf5]
Login

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

Overview
Comment:When flattening a SELECT query, do not discard collation sequences explicitly attached to expressions in the parent query. Fix for #3997. (CVS 6949)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b2784cf5d8b520fb714efdb2d2746b2c88b56edf
User & Date: danielk1977 2009-07-28 13:30:31
Context
2009-07-28
16:44
Add the experimental API sqlite3_strnicmp(). Modify fts3 so that in terms like 'column_name:token' the column_name is interpreted in a case-insenstive fashion. Ticket #3996. (CVS 6950) check-in: 4571aa9e user: danielk1977 tags: trunk
13:30
When flattening a SELECT query, do not discard collation sequences explicitly attached to expressions in the parent query. Fix for #3997. (CVS 6949) check-in: b2784cf5 user: danielk1977 tags: trunk
08:43
Fixed reversed labels in WHERETRACE() statement. Debugging code only. (CVS 6948) check-in: 614a8d83 user: shane 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.524 2009/06/12 03:27:27 drh Exp $
           15  +** $Id: select.c,v 1.525 2009/07/28 13:30:31 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Delete all the content of a Select structure but do not deallocate
    22     22   ** the select structure itself.
................................................................................
  2351   2351       if( pExpr->iColumn<0 ){
  2352   2352         pExpr->op = TK_NULL;
  2353   2353       }else{
  2354   2354         Expr *pNew;
  2355   2355         assert( pEList!=0 && pExpr->iColumn<pEList->nExpr );
  2356   2356         assert( pExpr->pLeft==0 && pExpr->pRight==0 );
  2357   2357         pNew = sqlite3ExprDup(db, pEList->a[pExpr->iColumn].pExpr, 0);
         2358  +      if( pExpr->pColl ){
         2359  +	pNew->pColl = pExpr->pColl;
         2360  +      }
  2358   2361         sqlite3ExprDelete(db, pExpr);
  2359   2362         pExpr = pNew;
  2360   2363       }
  2361   2364     }else{
  2362   2365       pExpr->pLeft = substExpr(db, pExpr->pLeft, iTable, pEList);
  2363   2366       pExpr->pRight = substExpr(db, pExpr->pRight, iTable, pEList);
  2364   2367       if( ExprHasProperty(pExpr, EP_xIsSelect) ){

Added test/tkt3997.test.

            1  +# 2001 September 15
            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  +#
           12  +# Tests to make sure #3997 is fixed.
           13  +#
           14  +# $Id: tkt3997.test,v 1.1 2009/07/28 13:30:31 danielk1977 Exp $
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +
           19  +proc reverse {lhs rhs} {
           20  +  return [string compare $rhs $lhs]
           21  +}
           22  +proc usual {lhs rhs} {
           23  +  return [string compare $lhs $rhs]
           24  +}
           25  +
           26  +db collate reverse reverse
           27  +db collate usual usual
           28  +
           29  +do_test tkt3997-1.1 {
           30  +  execsql {
           31  +    create table mytext(name BLOB);
           32  +    INSERT INTO mytext VALUES('abc');
           33  +    INSERT INTO mytext VALUES('acd');
           34  +    INSERT INTO mytext VALUES('afe');
           35  +  }
           36  +} {}
           37  +do_test tkt3997-1.2 {
           38  +  execsql { 
           39  +    SELECT name 
           40  +    FROM mytext 
           41  +    ORDER BY name COLLATE reverse 
           42  +  }
           43  +} {afe acd abc}
           44  +do_test tkt3997-1.3 {
           45  +  execsql { 
           46  +    SELECT name 
           47  +    FROM (SELECT name FROM mytext)  
           48  +    ORDER BY name COLLATE reverse 
           49  +  }
           50  +} {afe acd abc}
           51  +
           52  +do_test tkt3997-2.1 {
           53  +  execsql { 
           54  +    CREATE TABLE mytext2(name COLLATE reverse);
           55  +    INSERT INTO mytext2 SELECT name FROM mytext;
           56  +  }
           57  +} {}
           58  +do_test tkt3997-2.2 {
           59  +  execsql { 
           60  +    SELECT name 
           61  +    FROM (SELECT name FROM mytext2)  
           62  +    ORDER BY name
           63  +  }
           64  +} {afe acd abc}
           65  +do_test tkt3997-2.3 {
           66  +  execsql { 
           67  +    SELECT name 
           68  +    FROM (SELECT name FROM mytext2)
           69  +    ORDER BY name COLLATE usual
           70  +  }
           71  +} {abc acd afe}
           72  +
           73  +finish_test