mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug #27229: crash when a set function aggregated in outer
context was used as an argument of GROUP_CONCAT. Ensured correct setting of the depended_from field in references generated for set functions aggregated in outer selects. A wrong value of this field resulted in wrong maps returned by used_tables() for these references. Made sure that a temporary table field is added for any set function aggregated in outer context when creation of a temporary table is needed to execute the inner subquery. mysql-test/r/subselect.result: Added a test case for bug #27229. mysql-test/t/subselect.test: Added a test case for bug #27229. sql/item.cc: Fixed bug #27229: crash when a set function aggregated in outer context was used as an argument of GROUP_CONCAT. Ensured correct setting of the depended_from field in references generated for set functions aggregated in outer selects. sql/item_sum.cc: Fixed bug #27229: crash when a set function aggregated in outer context was used as an argument of GROUP_CONCAT. Added the field aggr_sel to the objects of the class Item_sum. In any Item_sum object created for a set function this field has to contain a pointer to the select where the set function is aggregated. sql/item_sum.h: Fixed bug #27229: crash when a set function aggregated in outer context was used as an argument of GROUP_CONCAT. Added the field aggr_sel to the objects of the class Item_sum. In any Item_sum object created for a set function this field has to contain a pointer to the select where the set function is aggregated. Added a method that says whether a set function is aggregated in outer context and, if so, returns the aggregating select. Removed the field nest_level_tables_count introduced by the patch for bug 24484 as aggr_sel->join->tables contains the sane number. sql/sql_base.cc: Fixed bug #27229: crash when a set function aggregated in outer context was used as an argument of GROUP_CONCAT. Added the field aggr_sel to the objects of the class Item_sum. Removed changes introduced by the patch for bug 24484 as the field leaf_count of the THD class is not used anymore. sql/sql_class.h: Fixed bug #27229: crash when a set function aggregated in outer context was used as an argument of GROUP_CONCAT. Added the field aggr_sel to the objects of the class Item_sum. Removed changes introduce by the patch for bug 24484 as the field leaf_count of the THD class is not used anymore. sql/sql_insert.cc: Fixed bug #27229: crash when a set function aggregated in outer context was used as an argument of GROUP_CONCAT. Added the field aggr_sel to the objects of the class Item_sum. Removed changes introduce by the patch for bug 24484 as the field leaf_count of the THD class is not used anymore. sql/sql_select.cc: Fixed bug #27229: crash when a set function aggregated in outer context was used as an argument of GROUP_CONCAT. When creating a temporary table a field is added in it for any set function aggregated in outer context.
This commit is contained in:
@ -3905,3 +3905,22 @@ COUNT(*) a
|
||||
2 2
|
||||
3 3
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
CREATE TABLE t2 (m int, n int);
|
||||
INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4);
|
||||
INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44);
|
||||
SELECT COUNT(*) c, a,
|
||||
(SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a)
|
||||
FROM t1 GROUP BY a;
|
||||
c a (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a)
|
||||
2 2 2
|
||||
3 3 3
|
||||
1 4 1,1
|
||||
SELECT COUNT(*) c, a,
|
||||
(SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a)
|
||||
FROM t1 GROUP BY a;
|
||||
c a (SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a)
|
||||
2 2 3
|
||||
3 3 4
|
||||
1 4 2,2
|
||||
DROP table t1,t2;
|
||||
|
@ -2763,3 +2763,22 @@ SELECT COUNT(*), a
|
||||
HAVING (SELECT MIN(m) FROM t2 WHERE m = count(*)) > 1;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug #27229: GROUP_CONCAT in subselect with COUNT() as an argument
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
CREATE TABLE t2 (m int, n int);
|
||||
INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4);
|
||||
INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44);
|
||||
|
||||
SELECT COUNT(*) c, a,
|
||||
(SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a)
|
||||
FROM t1 GROUP BY a;
|
||||
|
||||
SELECT COUNT(*) c, a,
|
||||
(SELECT GROUP_CONCAT(COUNT(a)+1) FROM t2 WHERE m = a)
|
||||
FROM t1 GROUP BY a;
|
||||
|
||||
DROP table t1,t2;
|
||||
|
Reference in New Issue
Block a user