/ Check-in [9e1f837b]
Login

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

Overview
Comment:Correctly handle COLLATE operators applied to COLLATE operators in an ORDER BY clause.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9e1f837b08facbc7a2b6196770599a58233e725c
User & Date: drh 2015-04-15 05:57:50
Context
2015-04-15
06:45
Fix a faulty assert() statement in the name resolver associated with the optimization that converts compound selects with ORDER BY COLLATE into subqueries. check-in: c72324ef user: drh tags: trunk
05:57
Correctly handle COLLATE operators applied to COLLATE operators in an ORDER BY clause. check-in: 9e1f837b user: drh tags: trunk
05:38
Fix a faulty assert() in the sqlite3StrAccumAppend() routine. check-in: 998cfdb8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

   990    990           Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
   991    991           if( pNew==0 ) return 1;
   992    992           pNew->flags |= EP_IntValue;
   993    993           pNew->u.iValue = iCol;
   994    994           if( pItem->pExpr==pE ){
   995    995             pItem->pExpr = pNew;
   996    996           }else{
   997         -          assert( pItem->pExpr->op==TK_COLLATE );
   998         -          assert( pItem->pExpr->pLeft==pE );
   999         -          pItem->pExpr->pLeft = pNew;
          997  +          Expr *pParent = pItem->pExpr;
          998  +          assert( pParent->op==TK_COLLATE );
          999  +          while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
         1000  +          assert( pParent->pLeft==pE );
         1001  +          pParent->pLeft = pNew;
  1000   1002           }
  1001   1003           sqlite3ExprDelete(db, pE);
  1002   1004           pItem->u.x.iOrderByCol = (u16)iCol;
  1003   1005           pItem->done = 1;
  1004   1006         }else{
  1005   1007           moreToDo = 1;
  1006   1008         }

Changes to test/collate1.test.

   381    381   
   382    382     INSERT INTO c1 VALUES(2, 'abb');
   383    383     INSERT INTO c1 VALUES(3, 'wxz');
   384    384     INSERT INTO c1 VALUES(4, 'WXY');
   385    385     SELECT x, y FROM c1 ORDER BY y COLLATE """""""";
   386    386   } {2 abb 1 ABC 4 WXY 3 wxz}
   387    387   
   388         -finish_test
          388  +# 2015-04-15:  Nested COLLATE operators
          389  +#
          390  +do_execsql_test 7.0 {
          391  +   SELECT 'abc' UNION ALL SELECT 'DEF'
          392  +    ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE nocase;
          393  +} {abc DEF}
          394  +do_execsql_test 7.1 {
          395  +   SELECT 'abc' UNION ALL SELECT 'DEF'
          396  +    ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE binary;
          397  +} {DEF abc}
          398  +do_execsql_test 7.2 {
          399  +   SELECT 'abc' UNION ALL SELECT 'DEF'
          400  +    ORDER BY 1 COLLATE binary COLLATE binary COLLATE binary COLLATE nocase;
          401  +} {abc DEF}
   389    402   
   390    403   
          404  +finish_test