]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
:-) (CVS 78)
authordrh <drh@noemail.net>
Thu, 8 Jun 2000 11:13:01 +0000 (11:13 +0000)
committerdrh <drh@noemail.net>
Thu, 8 Jun 2000 11:13:01 +0000 (11:13 +0000)
FossilOrigin-Name: 923c14fe120c7d5470a18257659154c4f98226b7

manifest
manifest.uuid
src/select.c
test/select5.test [new file with mode: 0644]

index 216564943df3b47fa6a86475878fa07767c2c49d..1d352c9d74ee3ee535d8336feddbdbca7d54b930 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C :-)\s(CVS\s77)
-D 2000-06-08T01:55:30
+C :-)\s(CVS\s78)
+D 2000-06-08T11:13:02
 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
 F Makefile.in 17ba1ccf8d2d40c627796bba8f72952365d6d644
 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -14,7 +14,7 @@ F src/expr.c baa8a4229b3acf69d908efcd697ab63922009c9f
 F src/insert.c ac4edfff474589c00b2490f206317dc5822122e5
 F src/main.c e3297835b8e38ca726ac73f2c2bdb7cf08103197
 F src/parse.y bb2126c8313c111184b89af8675911dcb57f1dca
-F src/select.c 561f34a8586ea6f459db58c72cdca5ab1b860eb4
+F src/select.c f3720cad997e37326490531c0e0eb6148d78f9b5
 F src/shell.c 3f4afc39a36e4824e8aa262623fd03568874799e
 F src/sqlite.h 58da0a8590133777b741f9836beaef3d58f40268
 F src/sqliteInt.h 816c491f9896090dde03804fd3f60346456b99df
@@ -39,6 +39,7 @@ F test/select1.test 64703852af34c85bb31b0a74bd73b340e8267f42
 F test/select2.test 3cd3c0f9d67e98b1b54af5853679b4a111224410
 F test/select3.test 73ae8c7b80c4e03a9c29d12f2ea1782e28b8e61f
 F test/select4.test 5d6aa52fde345c51784202159bf9695cd9cc68b7
+F test/select5.test 052369e09b332eae39f000514d6d781f6e2db4ab
 F test/sort.test d582086c4bb7df3fbf50aa72e69d7e235e9f8e31
 F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5
 F test/table.test 85d6f410d127ec508c6640f02d7c40d218414e81
@@ -55,7 +56,7 @@ F www/c_interface.tcl 9ac800854272db5fe439e07b7435b243a5422293
 F www/changes.tcl 04e66b4257589ff78a7e1de93e9dda4725fb03d6
 F www/index.tcl 52e29a4eeda8d59e91af43c61fef177c5f2ffd53
 F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd
-P 19029233082e319d4bfd94b22a694c917d8f0296
-R b1183616f00c47fc9f7cd8d8d2c10c1d
+P b3fb15ccde399318bde8c87362ecaa3a744f0680
+R e1672f296e56c45817b7370276066484
 U drh
-Z cce8eb07b73528634ac6a71a0e43523e
+Z c0fe15cc0f04489c1fb9cea7fed8a18a
index 87813b5a0720f4176f8221c90c2d2a4e92298b39..c8eca90f98524b9dcfe7f54f537c0a189b547398 100644 (file)
@@ -1 +1 @@
-b3fb15ccde399318bde8c87362ecaa3a744f0680
\ No newline at end of file
+923c14fe120c7d5470a18257659154c4f98226b7
\ No newline at end of file
index 16c90c1006eb71f405407ad1241ac150639c867e..ffe539d918843b845944392d2b1513a80415fea3 100644 (file)
@@ -24,7 +24,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements.
 **
-** $Id: select.c,v 1.19 2000/06/08 01:55:30 drh Exp $
+** $Id: select.c,v 1.20 2000/06/08 11:13:02 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -796,6 +796,13 @@ int sqliteSelect(
     if( pHaving && sqliteExprAnalyzeAggregates(pParse, pHaving) ){
       return 1;
     }
+    if( pOrderBy ){
+      for(i=0; i<pOrderBy->nExpr; i++){
+        if( sqliteExprAnalyzeAggregates(pParse, pOrderBy->a[i].pExpr) ){
+          return 1;
+        }
+      }
+    }
   }
 
   /* Begin generating code.
diff --git a/test/select5.test b/test/select5.test
new file mode 100644 (file)
index 0000000..f6c54ee
--- /dev/null
@@ -0,0 +1,59 @@
+# Copyright (c) 1999, 2000 D. Richard Hipp
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA  02111-1307, USA.
+#
+# Author contact information:
+#   drh@hwaci.com
+#   http://www.hwaci.com/drh/
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this file is testing aggregate functions and the
+# GROUP BY and HAVING clauses of SELECT statements.
+#
+# $Id: select5.test,v 1.1 2000/06/08 11:13:02 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Build some test data
+#
+set fd [open data1.txt w]
+for {set i 1} {$i<32} {incr i} {
+  for {set j 0} {pow(2,$j)<$i} {incr j} {}
+  puts $fd "[expr {32-$i}]\t[expr {10-$j}]"
+}
+close $fd
+execsql {
+  CREATE TABLE t1(x int, y int);
+  COPY t1 FROM 'data1.txt'
+}
+file delete data1.txt
+
+do_test select5-1.0 {
+  execsql {SELECT DISTINCT y FROM t1 ORDER BY y}
+} {5 6 7 8 9 10}
+
+# Sort by an aggregate function.
+#
+do_test select5-1.1 {
+  execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY y}
+} {5 15 6 8 7 4 8 2 9 1 10 1}
+do_test select5-1.2 {
+  execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY count(*), y}
+} {9 1 10 1 8 2 7 4 6 8 5 15}
+
+finish_test