summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2005-01-22 02:40:27 -0800
committerunknown <igor@rurik.mysql.com>2005-01-22 02:40:27 -0800
commit25c2d1adb09a3dd521a110013ab03eac3e1fc01a (patch)
tree90460d8fd1c844f7b11a3d231d91cb3d16e21035 /mysql-test
parent89a24f933537f550844862d936ed57b44ec16069 (diff)
downloadmariadb-git-25c2d1adb09a3dd521a110013ab03eac3e1fc01a.tar.gz
select_found.result, select_found.test:
Added a test case for bug #7945. sql_select.cc: Fixed bug #7945. If DISTINCT is used only with constants in a query with GROUP BY, we can apply an optimization that set LIMIT to 1 only in the case when there is no SQL_CALC_FOUND_ROWS. sql/sql_select.cc: Fixed bug #7945. If DISTINCT is used only with constants in a query with GROUP BY, we can apply an optimization that set LIMIT to 1 only in the case when there is no SQL_CALC_FOUND_ROWS. mysql-test/t/select_found.test: Added a test case for bug #7945. mysql-test/r/select_found.result: Added a test case for bug #7945.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/select_found.result8
-rw-r--r--mysql-test/t/select_found.test9
2 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result
index 444124bcd67..11629addba4 100644
--- a/mysql-test/r/select_found.result
+++ b/mysql-test/r/select_found.result
@@ -223,3 +223,11 @@ SELECT FOUND_ROWS();
FOUND_ROWS()
0
DROP TABLE t1;
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5);
+SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2;
+a
+a
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+1
diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test
index 7599277a867..997cadc2992 100644
--- a/mysql-test/t/select_found.test
+++ b/mysql-test/t/select_found.test
@@ -146,3 +146,12 @@ INSERT INTO t1 VALUES (0), (0), (1), (2);
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10;
SELECT FOUND_ROWS();
DROP TABLE t1;
+
+#
+# Bug #7945: group by + distinct with constant expression + limit
+#
+
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5);
+SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2;
+SELECT FOUND_ROWS();