Skip to content

Commit c896749

Browse files
committed
merge
2 parents a79187b + d765e30 commit c896749

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

mysql-test/r/group_by.result

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,41 @@ MAX(t2.a)
18111811
2
18121812
DROP TABLE t1, t2;
18131813
#
1814+
# Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results
1815+
#
1816+
CREATE TABLE t1 (a text, b varchar(10));
1817+
INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two');
1818+
EXPLAIN
1819+
SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
1820+
id 1
1821+
select_type SIMPLE
1822+
table t1
1823+
type ALL
1824+
possible_keys NULL
1825+
key NULL
1826+
key_len NULL
1827+
ref NULL
1828+
rows 2
1829+
Extra Using filesort
1830+
SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
1831+
SUBSTRING(a,1,10) LENGTH(a) GROUP_CONCAT(b)
1832+
1111111111 1300 one,two
1833+
EXPLAIN
1834+
SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
1835+
id 1
1836+
select_type SIMPLE
1837+
table t1
1838+
type ALL
1839+
possible_keys NULL
1840+
key NULL
1841+
key_len NULL
1842+
ref NULL
1843+
rows 2
1844+
Extra Using temporary; Using filesort
1845+
SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
1846+
SUBSTRING(a,1,10) LENGTH(a)
1847+
1111111111 1300
1848+
DROP TABLE t1;
18141849
# End of 5.1 tests
18151850
#
18161851
# Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00

mysql-test/t/group_by.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,20 @@ DROP TABLE t1, t2;
12221222

12231223

12241224
--echo #
1225+
--echo # Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results
1226+
--echo #
1227+
1228+
CREATE TABLE t1 (a text, b varchar(10));
1229+
INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two');
1230+
1231+
query_vertical EXPLAIN
1232+
SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
1233+
SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
1234+
query_vertical EXPLAIN
1235+
SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
1236+
SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
1237+
DROP TABLE t1;
1238+
12251239

12261240
--echo # End of 5.1 tests
12271241

sql/item.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,6 +2982,7 @@ class Cached_item :public Sql_alloc
29822982
class Cached_item_str :public Cached_item
29832983
{
29842984
Item *item;
2985+
uint32 value_max_length;
29852986
String value,tmp_value;
29862987
public:
29872988
Cached_item_str(THD *thd, Item *arg);

sql/item_buff.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ Cached_item::~Cached_item() {}
6565
*/
6666

6767
Cached_item_str::Cached_item_str(THD *thd, Item *arg)
68-
:item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
68+
:item(arg),
69+
value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
70+
value(value_max_length)
6971
{}
7072

7173
bool Cached_item_str::cmp(void)
@@ -74,7 +76,7 @@ bool Cached_item_str::cmp(void)
7476
bool tmp;
7577

7678
if ((res=item->val_str(&tmp_value)))
77-
res->length(min(res->length(), value.alloced_length()));
79+
res->length(min(res->length(), value_max_length));
7880
if (null_value != item->null_value)
7981
{
8082
if ((null_value= item->null_value))

0 commit comments

Comments
 (0)