views:

208

answers:

1

Somehow GROUP_CONCAT is able to round up six "pages" of an article (each stored as TEXT) and toss them into a single MEDIUMTEXT without losing any data, but there are some one-page articles that are longer than normal (but still obviously fit within the TEXT data type) that lose a significant amount of data. Anyone know what's up?

Original query:

SET group_concat_max_len = 16000000;
UPDATE Threads t SET t.Content = (SELECT GROUP_CONCAT(a.Content ORDER
BY a.PageID SEPARATOR '<!-- pagebreak -->') FROM MSarticlepages a
WHERE a.ArticleID = t.MSthreadID GROUP BY a.ArticleID);

Thanks again for taking the time to guide my ignorant self!

+1  A: 

The reference manual for MySQL 5.0 (http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat) states:

Beginning with MySQL 5.0.19, the type returned by GROUP_CONCAT() is always VARCHAR unless group_concat_max_len is greater than 512, in which case, it returns a BLOB. (Previously, it returned a BLOB with group_concat_max_len greater than 512 only if the query included an ORDER BY clause.)

Based on this data, the return type would be BLOB, not MEDIUMTEXT. Wwould it be possible that the concatenation in total is over 2^16 (65536 bytes), which is the limit for BLOB?

tehvan