summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-07-30 16:56:57 +0300
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-07-30 16:56:57 +0300
commit1560eab136642c19773f71e855e5696226cfd94f (patch)
tree3c3efc605b2176abeeadaa0a70a061877360cc4e
parentab20577be5d34daed7ae772285d069af59d09dee (diff)
parentde5029a4586176b9fed06ab96fb3a6e0bbcd8c54 (diff)
downloadmariadb-git-1560eab136642c19773f71e855e5696226cfd94f.tar.gz
merge
-rw-r--r--mysql-test/r/group_by.result35
-rw-r--r--mysql-test/t/group_by.test14
-rw-r--r--sql/item.h1
-rw-r--r--sql/item_buff.cc6
4 files changed, 54 insertions, 2 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 3416e368dff..2621f69da06 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1811,6 +1811,41 @@ MAX(t2.a)
2
DROP TABLE t1, t2;
#
+# Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results
+#
+CREATE TABLE t1 (a text, b varchar(10));
+INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two');
+EXPLAIN
+SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
+id 1
+select_type SIMPLE
+table t1
+type ALL
+possible_keys NULL
+key NULL
+key_len NULL
+ref NULL
+rows 2
+Extra Using filesort
+SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
+SUBSTRING(a,1,10) LENGTH(a) GROUP_CONCAT(b)
+1111111111 1300 one,two
+EXPLAIN
+SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
+id 1
+select_type SIMPLE
+table t1
+type ALL
+possible_keys NULL
+key NULL
+key_len NULL
+ref NULL
+rows 2
+Extra Using temporary; Using filesort
+SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
+SUBSTRING(a,1,10) LENGTH(a)
+1111111111 1300
+DROP TABLE t1;
# End of 5.1 tests
#
# Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index f46a20b2db4..2fb73af0c99 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1222,6 +1222,20 @@ DROP TABLE t1, t2;
--echo #
+--echo # Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results
+--echo #
+
+CREATE TABLE t1 (a text, b varchar(10));
+INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two');
+
+query_vertical EXPLAIN
+SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
+SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a;
+query_vertical EXPLAIN
+SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
+SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a;
+DROP TABLE t1;
+
--echo # End of 5.1 tests
diff --git a/sql/item.h b/sql/item.h
index c7a97ca716a..7f148a0a3e6 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2982,6 +2982,7 @@ public:
class Cached_item_str :public Cached_item
{
Item *item;
+ uint32 value_max_length;
String value,tmp_value;
public:
Cached_item_str(THD *thd, Item *arg);
diff --git a/sql/item_buff.cc b/sql/item_buff.cc
index a1bbd95c2c6..87197c7d9b6 100644
--- a/sql/item_buff.cc
+++ b/sql/item_buff.cc
@@ -65,7 +65,9 @@ Cached_item::~Cached_item() {}
*/
Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
+ :item(arg),
+ value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
+ value(value_max_length)
{}
bool Cached_item_str::cmp(void)
@@ -74,7 +76,7 @@ bool Cached_item_str::cmp(void)
bool tmp;
if ((res=item->val_str(&tmp_value)))
- res->length(min(res->length(), value.alloced_length()));
+ res->length(min(res->length(), value_max_length));
if (null_value != item->null_value)
{
if ((null_value= item->null_value))