summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_group.test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-08-10 16:45:02 +0300
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-08-10 16:45:02 +0300
commitd3dd6fa0084d6c89b71cb7d700a164a9f6e0da87 (patch)
tree08930b60207d2c18d8cacb4cfddc123087266207 /mysql-test/t/func_group.test
parent84ece59cefafc7a223c65aa7c763f5e72afaa1fc (diff)
downloadmariadb-git-d3dd6fa0084d6c89b71cb7d700a164a9f6e0da87.tar.gz
Bug #16792 query with subselect, join, and group not returning proper values
Treat queries with no FROM and aggregate functions as normal queries, so the aggregate function get correctly calculated as if there is 1 row. This means that they will be considered to have one row, so COUNT(*) will return 1 instead of 0. Other aggregates will behave in compatible manner. mysql-test/r/func_gconcat.result: Bug #16792 query with subselect, join, and group not returning proper values - test case. Note how it improves the support for DUAL. mysql-test/r/func_group.result: Bug #16792 query with subselect, join, and group not returning proper values - test case. Note how it improves the support for DUAL. mysql-test/r/subselect.result: Bug #16792 query with subselect, join, and group not returning proper values - consequence of (SELECT MAX(<const>)) now returning <const> instead of 0 mysql-test/t/func_group.test: Bug #16792 query with subselect, join, and group not returning proper values - test case. sql/opt_sum.cc: Bug #16792 query with subselect, join, and group not returning proper values - cannot do the optimization if the index is already opened by (say) UPDATE as it invloves opening reading and closing the index. sql/sql_select.cc: Bug #16792 query with subselect, join, and group not returning proper values - Treat queries with no FROM and aggregate functions as normal queries, so the aggregate function get correctly calculated as if there is 1 row.
Diffstat (limited to 'mysql-test/t/func_group.test')
-rw-r--r--mysql-test/t/func_group.test14
1 files changed, 14 insertions, 0 deletions
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index f8a3ed0f25e..18cb5d0a430 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -617,4 +617,18 @@ SELECT MAX(b) FROM t1;
EXPLAIN SELECT MAX(b) FROM t1;
DROP TABLE t1;
+#
+# Bug #16792 query with subselect, join, and group not returning proper values
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,3);
+
+SELECT (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a;
+SELECT (SELECT COUNT(DISTINCT 12)) FROM t1 GROUP BY t1.a;
+# an attempt to test all aggregate function with no table.
+SELECT AVG(2), BIT_AND(2), BIT_OR(2), BIT_XOR(2), COUNT(*), COUNT(12),
+ COUNT(DISTINCT 12), MIN(2),MAX(2),STD(2), VARIANCE(2),SUM(2),
+ GROUP_CONCAT(2),GROUP_CONCAT(DISTINCT 2);
+DROP TABLE t1;
+
# End of 4.1 tests