Bug #29504 GROUP_CONCAT truncates data after 1024 characters
Submitted: 3 Jul 2007 0:12 Modified: 3 Jul 2007 0:57
Reporter: Jared S (Silver Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.0.44 OS:Windows (Vista)
Assigned to: CPU Architecture:Any
Tags: 1024, group_concat, LENGTH

[3 Jul 2007 0:12] Jared S
Description:
Hi!

I am doing some data migration work at moment and am finding the GROUP_CONCAT function rather limited, it only allows for max of 1024 characters when I need 16K.

Please review this limitation.

How to repeat:
-- 1. Create DB called `test`
-- 2. Execute SP below
-- 3. Run SP below (takes just over 2 minutes)
-- 4. Click the disk icon in the results and save to \Desktop\results.txt
-- 5. Load results.txt into Notepad++ and move cursor to EOL 

-- RESULT Cursor Column in Notepad++ reads no more than 'col : 1025' 

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`MyProc` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `MyProc`()
BEGIN
DECLARE c INT;
-- vars
SET c = 0;
-- create talbe
DROP TABLE IF EXISTS `new table`;
CREATE TABLE `new table` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `description` varchar(45) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
-- truncate sale-business
truncate table classic.`sale-business`;
  -- insert
  WHILE c < 3100 DO
  -- INSERT INTO `new table`(description) VALUES(CAST(1 AS CHAR)); #too slow
  INSERT INTO `new table`(description) VALUES(c);
  SET c = c + 1;
  END WHILE;
-- group_concat error
SELECT GROUP_CONCAT(id) FROM `new table`;
END $$

DELIMITER ;

Suggested fix:
May I suggest max length of (16384) or (32768)
[3 Jul 2007 0:57] Jared S
Oops, looks like I skipped over documentation - group_concat_max_len