title: Mysql procedure does not execute as expected
body: <p>Using mysql 5.7, when I execute this procedure:</p>
  
  <pre><code>DELIMITER $$
  CREATE PROCEDURE tres()
  BEGIN
      DECLARE maxid INT;
      DECLARE x INT;
      SET maxid = 655;
      SET x=1;
      WHILE x&lt;= maxid DO 
          INSERT INTO `forum_topicresponder` (topic_id, username, reply_id) SELECT p.topic_id, p.creator_name, p.id  FROM forum_post AS p  WHERE p.topic_id=x;
       SET  x = x + 1; 
       END WHILE;
  END$$
  </code></pre>
  
  <p>I get</p>
  
  <blockquote>
    <p>mysql> call tres();<br>
    Query OK, 0 rows affected (3.49 sec)</p>
  </blockquote>
  
  <p>However when I execute the INSERT for a certain values inside the loop range:</p>
  
  <pre><code> INSERT INTO `forum_topicresponder` (topic_id, username, reply_id) SELECT p.topic_id, p.creator_name, p.id  FROM forum_post AS p  WHERE p.topic_id=42;
  </code></pre>
  
  <p>I see that the results are inserted without problem. </p>
  
  <p>The table schemas:</p>
  
  <pre><code>CREATE TABLE `forum_topicresponder` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `topic_id` int(10) NOT NULL DEFAULT '0',
    `username` varchar(300) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'na',
    `reply_id` int(11) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>And</p>
  
  <pre><code>CREATE TABLE `forum_post` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `body` varchar(16000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
    `topic_id` int(11) NOT NULL DEFAULT '0',
    `creator_id` int(11) NOT NULL DEFAULT '0',
    `creator_name` varchar(30) NOT NULL DEFAULT 'NA',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=6264595 DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>So what could be wrong here and how can I fix it? </p>