mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Allow GROUP BY on non-aggregate queries. Ticket #1064 (CVS 2276)
FossilOrigin-Name: 0642d3e3d6636a5f922f75c05252c9c1372d3936
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is page cache subsystem.
|
||||
#
|
||||
# $Id: collate3.test,v 1.8 2005/01/22 03:39:39 danielk1977 Exp $
|
||||
# $Id: collate3.test,v 1.9 2005/01/26 03:58:36 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -114,11 +114,16 @@ do_test collate3-2.7.1 {
|
||||
SELECT count(*) FROM collate3t1 GROUP BY c1;
|
||||
}
|
||||
} {1 {no such collation sequence: string_compare}}
|
||||
# do_test collate3-2.7.2 {
|
||||
# catchsql {
|
||||
# SELECT * FROM collate3t1 GROUP BY c1;
|
||||
# }
|
||||
# } {1 {GROUP BY may only be used on aggregate queries}}
|
||||
do_test collate3-2.7.2 {
|
||||
catchsql {
|
||||
SELECT * FROM collate3t1 GROUP BY c1;
|
||||
}
|
||||
} {1 {GROUP BY may only be used on aggregate queries}}
|
||||
} {1 {no such collation sequence: string_compare}}
|
||||
do_test collate3-2.8 {
|
||||
catchsql {
|
||||
SELECT DISTINCT c1 FROM collate3t1;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# focus of this file is testing aggregate functions and the
|
||||
# GROUP BY and HAVING clauses of SELECT statements.
|
||||
#
|
||||
# $Id: select5.test,v 1.8 2004/08/20 18:34:20 drh Exp $
|
||||
# $Id: select5.test,v 1.9 2005/01/26 03:58:36 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -116,4 +116,41 @@ do_test select5-4.5 {
|
||||
}
|
||||
} {0.0}
|
||||
|
||||
# Some tests for queries with a GROUP BY clause but no aggregate functions.
|
||||
#
|
||||
# Note: The query in test case 5-5.5 are not legal SQL. So if the
|
||||
# implementation changes in the future and it returns different results,
|
||||
# this is not such a big deal.
|
||||
#
|
||||
do_test select5-5.1 {
|
||||
execsql {
|
||||
CREATE TABLE t2(a, b, c);
|
||||
INSERT INTO t2 VALUES(1, 2, 3);
|
||||
INSERT INTO t2 VALUES(1, 4, 5);
|
||||
INSERT INTO t2 VALUES(6, 4, 7);
|
||||
CREATE INDEX t2_idx ON t2(a);
|
||||
}
|
||||
} {}
|
||||
do_test select5-5.2 {
|
||||
execsql {
|
||||
SELECT a FROM t2 GROUP BY a;
|
||||
}
|
||||
} {1 6}
|
||||
do_test select5-5.3 {
|
||||
execsql {
|
||||
SELECT a FROM t2 WHERE a>2 GROUP BY a;
|
||||
}
|
||||
} {6}
|
||||
do_test select5-5.4 {
|
||||
execsql {
|
||||
SELECT a, b FROM t2 GROUP BY a, b;
|
||||
}
|
||||
} {1 2 1 4 6 4}
|
||||
do_test select5-5.5 {
|
||||
execsql {
|
||||
SELECT a, b FROM t2 GROUP BY a;
|
||||
}
|
||||
} {1 2 6 4}
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# focus of this file is testing compute SELECT statements and nested
|
||||
# views.
|
||||
#
|
||||
# $Id: select7.test,v 1.5 2005/01/21 03:12:16 danielk1977 Exp $
|
||||
# $Id: select7.test,v 1.6 2005/01/26 03:58:37 danielk1977 Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@@ -54,11 +54,20 @@ do_test select7-2.1 {
|
||||
|
||||
# Do not allow GROUP BY without an aggregate. Ticket #1039.
|
||||
#
|
||||
# Change: force any query with a GROUP BY clause to be processed as
|
||||
# an aggregate query, whether it contains aggregates or not.
|
||||
#
|
||||
ifcapable subquery {
|
||||
# do_test select7-3.1 {
|
||||
# catchsql {
|
||||
# SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name
|
||||
# }
|
||||
# } {1 {GROUP BY may only be used on aggregate queries}}
|
||||
do_test select7-3.1 {
|
||||
catchsql {
|
||||
SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name
|
||||
}
|
||||
} {1 {GROUP BY may only be used on aggregate queries}}
|
||||
} [list 0 [execsql {SELECT * FROM sqlite_master ORDER BY name}]]
|
||||
}
|
||||
finish_test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user