]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Disallow empty GROUP BY clauses. Ticket #2431. (CVS 4099)
authordrh <drh@noemail.net>
Wed, 20 Jun 2007 12:18:31 +0000 (12:18 +0000)
committerdrh <drh@noemail.net>
Wed, 20 Jun 2007 12:18:31 +0000 (12:18 +0000)
FossilOrigin-Name: 9581e7a4a4d74b08ce5380b49862957c804e46bb

manifest
manifest.uuid
src/parse.y
test/select3.test

index 74ec43a63bf72bd63c008e5a0c6f8372ff13b7bb..94c077f8a1dc21c884c89dd32292d9491ed0ad2f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Additional\schanges\sfor\sticket\s#2426.\s(CVS\s4098)
-D 2007-06-20T11:56:51
+C Disallow\sempty\sGROUP\sBY\sclauses.\s\sTicket\s#2431.\s(CVS\s4099)
+D 2007-06-20T12:18:31
 F Makefile.in 5babd49c427a0e82e849c89a4d3c3c1e607ec014
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -96,7 +96,7 @@ F src/os_win.c d868d5f9e95ec9c1b9e2a30c54c996053db6dddd
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
 F src/pager.c 39352b58ee840cae715a4f0d20e446aa5e1445fe
 F src/pager.h 94110a5570dca30d54a883e880a3633b2e4c05ae
-F src/parse.y 2ed1d91fdcb4ae7ae7d1f4674544297807c7cc26
+F src/parse.y ad2ce25665be7f7303137f774a4e3e72e0d036ff
 F src/pragma.c 0d25dad58bdfd6789943a10f1b9663c2eb85b96d
 F src/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089
 F src/printf.c 711908d6ff3385f9882df8ff405b9e0a2a4d04df
@@ -340,7 +340,7 @@ F test/schema.test b479341d04cc40a11f47929b0198c07ddd6b2565
 F test/schema2.test b438d2c7fd627227f405887c2328b4aed5dad012
 F test/select1.test 1a35bf8201c8a42a44d65acc3e6c9796a9c43dfb
 F test/select2.test f3c2678c3a9f3cf08ec4988a3845bda64be6d9e3
-F test/select3.test 2d473f45c57c0526833e045fca0537badec0dd04
+F test/select3.test 47439f28862489626b483b0c718cfb0562e6f6d5
 F test/select4.test 305ba0a6e97efc5544def5e5cb49b54e1bf87fd9
 F test/select5.test 0b47058d3e916c1fc9fe81f44b438e02bade21ce
 F test/select6.test 399f14b9ba37b768afe5d2cd8c12e4f340a69db8
@@ -508,7 +508,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P f025a745319486d858e2831178a86265fd5fcf32
-R aa0c290aec730ab79f90fd9070cb4470
+P 79debf95cdccdc1f18b6f0fcd213f514e327181c
+R 9993fe8d7ca1edb1600b61266ae9df74
 U drh
-Z d154e0e38a8408df243868876e3f2c61
+Z 88bcb70cc33bc6840bc6711d69f5e069
index 9824f22c7eb643810b539ee3507c2d3364cfd4fc..aad53505b6090c53ab73b0047c69b1ccff0822fb 100644 (file)
@@ -1 +1 @@
-79debf95cdccdc1f18b6f0fcd213f514e327181c
\ No newline at end of file
+9581e7a4a4d74b08ce5380b49862957c804e46bb
\ No newline at end of file
index 2433635eb191109eb04c187fbe0965db6fa3eddd..1de400f72ddc60a8b51d7ec285f34de0ce8b8010 100644 (file)
@@ -14,7 +14,7 @@
 ** the parser.  Lemon will also generate a header file containing
 ** numeric codes for all of the tokens.
 **
-** @(#) $Id: parse.y,v 1.230 2007/06/15 17:03:14 drh Exp $
+** @(#) $Id: parse.y,v 1.231 2007/06/20 12:18:31 drh Exp $
 */
 
 // All token codes are small integers with #defines that begin with "TK_"
@@ -536,7 +536,7 @@ sortorder(A) ::= .              {A = SQLITE_SO_ASC;}
 %type groupby_opt {ExprList*}
 %destructor groupby_opt {sqlite3ExprListDelete($$);}
 groupby_opt(A) ::= .                      {A = 0;}
-groupby_opt(A) ::= GROUP BY exprlist(X).  {A = X;}
+groupby_opt(A) ::= GROUP BY nexprlist(X). {A = X;}
 
 %type having_opt {Expr*}
 %destructor having_opt {sqlite3ExprDelete($$);}
@@ -849,14 +849,14 @@ case_operand(A) ::= .                   {A = 0;}
 
 %type exprlist {ExprList*}
 %destructor exprlist {sqlite3ExprListDelete($$);}
-%type expritem {Expr*}
-%destructor expritem {sqlite3ExprDelete($$);}
-
-exprlist(A) ::= exprlist(X) COMMA expritem(Y). 
-                                        {A = sqlite3ExprListAppend(X,Y,0);}
-exprlist(A) ::= expritem(X).            {A = sqlite3ExprListAppend(0,X,0);}
-expritem(A) ::= expr(X).                {A = X;}
-expritem(A) ::= .                       {A = 0;}
+%type nexprlist {ExprList*}
+%destructor nexprlist {sqlite3ExprListDelete($$);}
+
+exprlist(A) ::= nexprlist(X).                {A = X;}
+exprlist(A) ::= .                            {A = 0;}
+nexprlist(A) ::= nexprlist(X) COMMA expr(Y). {A = sqlite3ExprListAppend(X,Y,0);}
+nexprlist(A) ::= expr(Y).                    {A = sqlite3ExprListAppend(0,Y,0);}
+
 
 ///////////////////////////// The CREATE INDEX command ///////////////////////
 //
index 8d89dabbed54b2b7cc058a5a8932fccd047f4032..ec8245ab82072ddde4ca32a3af09628bd56cf12c 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing aggregate functions and the
 # GROUP BY and HAVING clauses of SELECT statements.
 #
-# $Id: select3.test,v 1.20 2007/02/24 11:52:55 drh Exp $
+# $Id: select3.test,v 1.21 2007/06/20 12:18:31 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -104,16 +104,18 @@ do_test select3-2.12 {
     SELECT log, count(*) FROM t1 GROUP BY 1 ORDER BY log;
   }
 } {0 {0 1 1 1 2 2 3 4 4 8 5 15}}
-#do_test select3-2.13 {
-#  catchsql {
-#    SELECT log, count(*) FROM t1 GROUP BY 2 ORDER BY log;
-#  }
-#} {0 {0 1 1 1 2 2 3 4 4 8 5 15}}
-#do_test select3-2.14 {
-#  catchsql {
-#    SELECT log, count(*) FROM t1 GROUP BY count(*) ORDER BY log;
-#  }
-#} {0 {0 1 1 1 2 2 3 4 4 8 5 15}}
+
+# Cannot have an empty GROUP BY
+do_test select3-2.13 {
+  catchsql {
+    SELECT log, count(*) FROM t1 GROUP BY ORDER BY log;
+  }
+} {1 {near "ORDER": syntax error}}
+do_test select3-2.14 {
+  catchsql {
+    SELECT log, count(*) FROM t1 GROUP BY;
+  }
+} {1 {near ";": syntax error}}
 
 # Cannot have a HAVING without a GROUP BY
 #