]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Propagate COLLATE operators upward through function calls and CASE operations.
authordrh <drh@noemail.net>
Mon, 9 Feb 2015 18:28:03 +0000 (18:28 +0000)
committerdrh <drh@noemail.net>
Mon, 9 Feb 2015 18:28:03 +0000 (18:28 +0000)
And do not flatten an aggregate subquery into a query that uses other
subqueries.  Fixes for tickets [ca0d20b6cdddec5] and
[2f7170d73bf9], respectively.

FossilOrigin-Name: 24e78b8d65734a6a8ae21a20542cd1839e756fb1

1  2 
manifest
manifest.uuid
src/expr.c

diff --cc manifest
index 13b7009965bf78000afa0872c6b773673efc582c,3dc1515cc4806d06087452d784006cbfb7db57f8..e802b5a3d1bb1c3e65c3ce892fefc8e5e1aad05b
+++ b/manifest
@@@ -1,5 -1,5 +1,5 @@@
- C Fix\sWITHOUT\sROWID\stable\shanding\sin\ssqlite3_analyzer.
- D 2015-02-09T17:46:11.315
 -C Add\stest\scases\sfor\sthe\squery\sflattener\sfix\sfor\nticket\s[2f7170d73bf9abf8].
 -D 2015-02-09T16:34:33.249
++C Propagate\sCOLLATE\soperators\supward\sthrough\sfunction\scalls\sand\sCASE\soperations.\nAnd\sdo\snot\sflatten\san\saggregate\ssubquery\sinto\sa\squery\sthat\suses\sother\nsubqueries.\s\sFixes\sfor\stickets\s[ca0d20b6cdddec5]\sand\n[2f7170d73bf9],\srespectively.
++D 2015-02-09T18:28:03.590
  F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
  F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46
  F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@@ -181,8 -181,8 +181,8 @@@ F src/callback.c 7b44ce59674338ad48b0e8
  F src/complete.c 198a0066ba60ab06fc00fba1998d870a4d575463
  F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887
  F src/date.c e4d50b3283696836ec1036b695ead9a19e37a5ac
- F src/delete.c bd1a91ddd247ce13004075251e0b7fe2bf9925ef
- F src/expr.c d66424535d3155eca7f2d8820d26b96870dfcb2d
+ F src/delete.c 37964e6c1d73ff49cbea9ff690c9605fb15f600e
 -F src/expr.c f40082f5d31a76ea53302e202899a4959555b009
++F src/expr.c 3ef111b88ae2941b84b6b6ea4be8d501ba1af0cb
  F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
  F src/fkey.c e0444b61bed271a76840cbe6182df93a9baa3f12
  F src/func.c 6d3c4ebd72aa7923ce9b110a7dc15f9b8c548430
@@@ -1239,7 -1239,7 +1239,8 @@@ F tool/vdbe_profile.tcl 67746953071a9f8
  F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
  F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
  F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
- P 4ef7ceced2b0000d21f7f8014384c04a0e4661d3
- R 3dfd2d57b7936b7d1030a6a9083d3a68
- U dan
- Z 936b36142dcc1fcccff0b983a2ef7c1f
 -P c053448a55f9d030e8ffe88cf4fc14ada7f6ec19
 -R 2d5172d7784b0dfa3e9c983c86806f6a
++P 937e0fe7008c0f76b6a584180df9a9457166a0b1 dd8f7f7511639a1baa41a6ff2e359dc6f1e66943
++R eaedb0adeed807300663dae355946d49
++T +closed dd8f7f7511639a1baa41a6ff2e359dc6f1e66943
+ U drh
 -Z 7fd9b7cb5d6f8f4f67ff4b5b0cf25a38
++Z 20be3d681a1333c92b781a8eb61382fe
diff --cc manifest.uuid
index dd3e606fa8935c13533a5edc1663180fbb954795,9cc0e5086e1ec85752fd3b97d2e12e765ca19231..1b38cd06bf3c8609ae762e3ba4c5b82f00c074ba
@@@ -1,1 -1,1 +1,1 @@@
- 937e0fe7008c0f76b6a584180df9a9457166a0b1
 -dd8f7f7511639a1baa41a6ff2e359dc6f1e66943
++24e78b8d65734a6a8ae21a20542cd1839e756fb1
diff --cc src/expr.c
index 2f0fe4a581e16369adeca8df0821483337d7bbda,496c7a317676fd2657955f190f26c9fdf06d0775..5457a9c0656c125f39b036ef155a3ca3aca41222
@@@ -146,10 -146,20 +146,25 @@@ CollSeq *sqlite3ExprCollSeq(Parse *pPar
        break;
      }
      if( p->flags & EP_Collate ){
-       if( ALWAYS(p->pLeft) && (p->pLeft->flags & EP_Collate)!=0 ){
+       if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){
          p = p->pLeft;
        }else{
-         p = p->pRight;
+         Expr *pNext  = p->pRight;
 -        if( p->x.pList!=0 && !ExprHasProperty(p, EP_xIsSelect) ){
++        /* The Expr.x union is never used at the same time as Expr.pRight */
++        assert( p->x.pList==0 || p->pRight==0 );
++        /* p->flags holds EP_Collate and p->pLeft->flags does not.  And
++        ** p->x.pSelect cannot.  So if p->x.pLeft exists, it must hold at
++        ** least one EP_Collate. Thus the following two ALWAYS. */
++        if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){
+           int i;
 -          for(i=0; i<p->x.pList->nExpr; i++){
++          for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){
+             if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
+               pNext = p->x.pList->a[i].pExpr;
+               break;
+             }
+           }
+         }
+         p = pNext;
        }
      }else{
        break;