diff options
author | Michael Widenius <monty@askmonty.org> | 2014-02-11 16:58:49 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2014-02-11 16:58:49 +0200 |
commit | 1bdf2151dad679a8c13d2856d3baa32515a6db35 (patch) | |
tree | 2d609f5dbc770a37dcdae4b7adb737bf0306515f /mysql-test | |
parent | 2d48e9f11c080573a961eac08bf920a258f1b2c1 (diff) | |
download | mariadb-git-1bdf2151dad679a8c13d2856d3baa32515a6db35.tar.gz |
Fixed MDEV-5617: mysqld crashes when running a query with ONLY_FULL_GROUP_BY
Problem was that we used cache_table in some cases where it was not initialized
mysql-test/r/func_group.result:
Added test case
mysql-test/t/func_group.test:
Added test case
sql/item.cc:
Don't use cached_table if not set
sql/item_sum.cc:
Don't use cached_table
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/func_group.result | 11 | ||||
-rw-r--r-- | mysql-test/t/func_group.test | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 8e50c045775..8e2bdeae93c 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1458,6 +1458,8 @@ DROP TABLE derived1; DROP TABLE D; CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1,1), (1,2), (1,3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); SET SQL_MODE='ONLY_FULL_GROUP_BY'; SELECT COUNT(*) FROM t1; COUNT(*) @@ -1473,12 +1475,19 @@ COUNT(*) SELECT COUNT(*), (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a) FROM t1 outr; ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause +SELECT COUNT(*) FROM t1 outr, (SELECT b, count(*) FROM t2) as t3; +ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause +SELECT COUNT(*) FROM t1 outr where (1,1) in (SELECT a, count(*) FROM t2); +COUNT(*) +0 SELECT COUNT(*) FROM t1 a JOIN t1 outr ON a.a= (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a); COUNT(*) 0 +SELECT * FROM (SELECT a FROM t1 GROUP BY a) sq JOIN t2 ON a = b; +a b SET SQL_MODE=default; -DROP TABLE t1; +DROP TABLE t1,t2; End of 5.0 tests # # BUG#47280 - strange results from count(*) with order by multiple diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index cf5f00c3ee1..363f089e8d7 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -981,10 +981,13 @@ DROP TABLE D; # # Bug #39656: Behaviour different for agg functions with & without where - # ONLY_FULL_GROUP_BY +# MDEV-5617 mysqld crashes when running a query with ONLY_FULL_GROUP_BY # CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1,1), (1,2), (1,3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); SET SQL_MODE='ONLY_FULL_GROUP_BY'; @@ -1000,11 +1003,18 @@ SELECT COUNT(*) FROM t1 a JOIN t1 b ON a.a= b.a; SELECT COUNT(*), (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a) FROM t1 outr; +--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +SELECT COUNT(*) FROM t1 outr, (SELECT b, count(*) FROM t2) as t3; + +SELECT COUNT(*) FROM t1 outr where (1,1) in (SELECT a, count(*) FROM t2); + SELECT COUNT(*) FROM t1 a JOIN t1 outr ON a.a= (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a); +SELECT * FROM (SELECT a FROM t1 GROUP BY a) sq JOIN t2 ON a = b; + SET SQL_MODE=default; -DROP TABLE t1; +DROP TABLE t1,t2; ### |