summaryrefslogtreecommitdiff
path: root/mysql-test/t/group_by.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/group_by.test')
-rw-r--r--mysql-test/t/group_by.test65
1 files changed, 57 insertions, 8 deletions
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 43274532b3e..d941fa22830 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -287,14 +287,14 @@ SELECT a,count(*) FROM t1 GROUP BY binary a;
SELECT binary a FROM t1 GROUP BY 1;
SELECT binary a,count(*) FROM t1 GROUP BY 1;
# Do the same tests with MyISAM temporary tables
-SET SQL_BIG_TABLES=1;
+SET BIG_TABLES=1;
SELECT a FROM t1 GROUP BY a;
SELECT a,count(*) FROM t1 GROUP BY a;
SELECT a FROM t1 GROUP BY binary a;
SELECT a,count(*) FROM t1 GROUP BY binary a;
SELECT binary a FROM t1 GROUP BY 1;
SELECT binary a,count(*) FROM t1 GROUP BY 1;
-SET SQL_BIG_TABLES=0;
+SET BIG_TABLES=0;
drop table t1;
#
@@ -391,7 +391,7 @@ drop table t1,t2,t3;
create table t1 (a blob null);
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(""),(""),(""),("b");
select a,count(*) from t1 group by a;
-set option sql_big_tables=1;
+set big_tables=1;
select a,count(*) from t1 group by a;
drop table t1;
@@ -1310,7 +1310,7 @@ DROP TABLE t1;
--echo # by functions
--echo #
-SET SQL_BIG_TABLES=1;
+SET BIG_TABLES=1;
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (0),(0);
SELECT 1 FROM t1 GROUP BY IF(`a`,'','');
@@ -1318,7 +1318,7 @@ SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND() FROM '');
SELECT 1 FROM t1 GROUP BY SUBSTRING('',SLEEP(0),'');
SELECT 1 FROM t1 GROUP BY SUBSTRING(SYSDATE() FROM 'K' FOR 'jxW<');
DROP TABLE t1;
-SET SQL_BIG_TABLES=0;
+SET BIG_TABLES=0;
--echo #
--echo # MDEV-641 LP:1002108 - Wrong result (or crash) from a query with duplicated field in the group list and a limit clause
@@ -1334,7 +1334,7 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
let $query0=SELECT col1 AS field1, col1 AS field2
- FROM t1 GROUP BY field1, field2+0;
+ FROM t1 GROUP BY field1, field2;
# Needs to be range to exercise bug
--eval EXPLAIN $query0;
@@ -1496,8 +1496,7 @@ CREATE TABLE t1 (
b varchar(1),
KEY (b,a)
);
-
-INSERT INTO t1 VALUES (1,NULL),(0,'a');
+INSERT INTO t1 VALUES (1,NULL),(0,'a'),(1,NULL),(0,'a');
let $query=
SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b;
@@ -1770,3 +1769,53 @@ DROP TABLE t1;
#
# End of MariaDB 5.5 tests
#
+
+--echo #
+--echo # Bug #58782
+--echo # Missing rows with SELECT .. WHERE .. IN subquery
+--echo # with full GROUP BY and no aggr
+--echo #
+
+CREATE TABLE t1 (
+ pk INT NOT NULL,
+ col_int_nokey INT,
+ PRIMARY KEY (pk)
+);
+
+INSERT INTO t1 VALUES (10,7);
+INSERT INTO t1 VALUES (11,1);
+INSERT INTO t1 VALUES (12,5);
+INSERT INTO t1 VALUES (13,3);
+
+## original query:
+
+SELECT pk AS field1, col_int_nokey AS field2
+FROM t1
+WHERE col_int_nokey > 0
+GROUP BY field1, field2;
+
+## store query results in a new table:
+
+CREATE TABLE where_subselect
+ SELECT pk AS field1, col_int_nokey AS field2
+ FROM t1
+ WHERE col_int_nokey > 0
+ GROUP BY field1, field2
+;
+
+## query the new table and compare to original using WHERE ... IN():
+
+SELECT *
+FROM where_subselect
+WHERE (field1, field2) IN (
+ SELECT pk AS field1, col_int_nokey AS field2
+ FROM t1
+ WHERE col_int_nokey > 0
+ GROUP BY field1, field2
+);
+
+DROP TABLE t1;
+DROP TABLE where_subselect;
+
+--echo # End of Bug #58782
+