I have a stored procedure as described below.
DROP PROCEDURE `GetVoteID`//
CREATE DEFINER=`u1037413_manager`@`%` PROCEDURE `GetVoteID`(IN minimum_votes INT(11), IN current_round INT(11), INOUT votes_id TEXT)
BEGIN
SET SESSION group_concat_max_len = 100000;
SET @eliminated_candidates := (
SELECT GROUP_CONCAT(CONVERT(vote_candidate, CHAR(11)))
FROM vote_final
WHERE votes = minimum_votes
AND round_id = current_round
);
SELECT GROUP_CONCAT(CONVERT(vote_id, CHAR(11))) INTO votes_id
FROM votes_copy
WHERE FIND_IN_SET(vote_candidate_1, @eliminated_candidates) != 0;
END
Since I'm using a group_concat that produces quite long strings in both the set-statement and the select-statement I need to change the sessions group_concat_max_len to 100000 chars. But this is where I run into problems. Using this method I've figured out that SET SESSION group_concat_max_len = 100000;
really never changes the limit. When the length of @votes_id reaches 1,024 it's content is truncated - even though I've changed the limit to 100,000.
CALL GetVoteID(501,3,@votes_id);
SELECT sum(char_length(@votes_id));
This leaves me with two questions.
- When does this session actually end? At the end of the stored procedure or at the end of each statement within the procedure?
- What am I doing wrong with the
group_concat_max_len
?
SHOW VARIABLES LIKE 'max_allowed_packet';
returns 4194304. I'm running this on a hosted server so changing this in my.ini file is not possible.SELECT sum(char_length(@votes_id));
SELECT sum(char_length(votes_id));