Loading mysql-test/r/func_gconcat.result +13 −0 Original line number Diff line number Diff line Loading @@ -641,3 +641,16 @@ select charset(group_concat(c1 order by c2)) from t1; charset(group_concat(c1 order by c2)) latin1 drop table t1; CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a)); SET GROUP_CONCAT_MAX_LEN = 20000000; INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000)); INSERT INTO t1 SELECT a + 1, b FROM t1; SELECT a, CHAR_LENGTH(b) FROM t1; a CHAR_LENGTH(b) 1 120000 2 120000 SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1; CHAR_LENGTH( GROUP_CONCAT(b) ) 240001 SET GROUP_CONCAT_MAX_LEN = 1024; DROP TABLE t1; mysql-test/t/func_gconcat.test +14 −0 Original line number Diff line number Diff line Loading @@ -433,3 +433,17 @@ create table t1 (c1 varchar(10), c2 int); select charset(group_concat(c1 order by c2)) from t1; drop table t1; # # Bug #16712: group_concat returns odd string instead of intended result # CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a)); SET GROUP_CONCAT_MAX_LEN = 20000000; INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000)); INSERT INTO t1 SELECT a + 1, b FROM t1; SELECT a, CHAR_LENGTH(b) FROM t1; SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1; SET GROUP_CONCAT_MAX_LEN = 1024; DROP TABLE t1; sql/item_sum.cc +7 −1 Original line number Diff line number Diff line Loading @@ -377,7 +377,13 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table, case INT_RESULT: return new Field_longlong(max_length,maybe_null,name,table,unsigned_flag); case STRING_RESULT: if (max_length/collation.collation->mbmaxlen > 255 && convert_blob_length) /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ if (max_length/collation.collation->mbmaxlen > 255 && max_length/collation.collation->mbmaxlen < UINT_MAX16 && convert_blob_length) return new Field_varstring(convert_blob_length, maybe_null, name, table, collation.collation); Loading sql/sql_select.cc +12 −2 Original line number Diff line number Diff line Loading @@ -8034,7 +8034,12 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field, { Field *new_field; if (convert_blob_length && (org_field->flags & BLOB_FLAG)) /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ if (convert_blob_length && convert_blob_length < UINT_MAX16 && (org_field->flags & BLOB_FLAG)) new_field= new Field_varstring(convert_blob_length, org_field->maybe_null(), org_field->field_name, table, Loading Loading @@ -8116,8 +8121,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, if ((type= item->field_type()) == MYSQL_TYPE_DATETIME || type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE) new_field= item->tmp_table_field_from_field_type(table); /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ else if (item->max_length/item->collation.collation->mbmaxlen > 255 && convert_blob_length) item->max_length/item->collation.collation->mbmaxlen < UINT_MAX16 && convert_blob_length) new_field= new Field_varstring(convert_blob_length, maybe_null, item->name, table, item->collation.collation); Loading Loading
mysql-test/r/func_gconcat.result +13 −0 Original line number Diff line number Diff line Loading @@ -641,3 +641,16 @@ select charset(group_concat(c1 order by c2)) from t1; charset(group_concat(c1 order by c2)) latin1 drop table t1; CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a)); SET GROUP_CONCAT_MAX_LEN = 20000000; INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000)); INSERT INTO t1 SELECT a + 1, b FROM t1; SELECT a, CHAR_LENGTH(b) FROM t1; a CHAR_LENGTH(b) 1 120000 2 120000 SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1; CHAR_LENGTH( GROUP_CONCAT(b) ) 240001 SET GROUP_CONCAT_MAX_LEN = 1024; DROP TABLE t1;
mysql-test/t/func_gconcat.test +14 −0 Original line number Diff line number Diff line Loading @@ -433,3 +433,17 @@ create table t1 (c1 varchar(10), c2 int); select charset(group_concat(c1 order by c2)) from t1; drop table t1; # # Bug #16712: group_concat returns odd string instead of intended result # CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a)); SET GROUP_CONCAT_MAX_LEN = 20000000; INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000)); INSERT INTO t1 SELECT a + 1, b FROM t1; SELECT a, CHAR_LENGTH(b) FROM t1; SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1; SET GROUP_CONCAT_MAX_LEN = 1024; DROP TABLE t1;
sql/item_sum.cc +7 −1 Original line number Diff line number Diff line Loading @@ -377,7 +377,13 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table, case INT_RESULT: return new Field_longlong(max_length,maybe_null,name,table,unsigned_flag); case STRING_RESULT: if (max_length/collation.collation->mbmaxlen > 255 && convert_blob_length) /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ if (max_length/collation.collation->mbmaxlen > 255 && max_length/collation.collation->mbmaxlen < UINT_MAX16 && convert_blob_length) return new Field_varstring(convert_blob_length, maybe_null, name, table, collation.collation); Loading
sql/sql_select.cc +12 −2 Original line number Diff line number Diff line Loading @@ -8034,7 +8034,12 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field, { Field *new_field; if (convert_blob_length && (org_field->flags & BLOB_FLAG)) /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ if (convert_blob_length && convert_blob_length < UINT_MAX16 && (org_field->flags & BLOB_FLAG)) new_field= new Field_varstring(convert_blob_length, org_field->maybe_null(), org_field->field_name, table, Loading Loading @@ -8116,8 +8121,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, if ((type= item->field_type()) == MYSQL_TYPE_DATETIME || type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE) new_field= item->tmp_table_field_from_field_type(table); /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ else if (item->max_length/item->collation.collation->mbmaxlen > 255 && convert_blob_length) item->max_length/item->collation.collation->mbmaxlen < UINT_MAX16 && convert_blob_length) new_field= new Field_varstring(convert_blob_length, maybe_null, item->name, table, item->collation.collation); Loading