title: Lost connection to server with show create function
body: <p>I've seen the familiar Lost connection to MySQL server during query error before, with large data sets and the like. What I've not seen, but am now seeing, is that message when running <code>SHOW CREATE FUNCTION</code>. The function is only about 20 lines long and seems to have no syntax errors. I am able to drop and recreate it without issue (using a definition from a back up). If I create the same function with a different name, I get no error. But with the original name, I get the error. What can I do to fix this?</p>
  <p>The function in question:</p>
  <pre><code>DELIMITER$$
  
  DROP FUNCTION IF EXISTS `check_address`$$
  
  CREATE FUNCTION `check_address`(
      _loan_id BIGINT,
      _address1 VARCHAR(255),
      _address2 VARCHAR(255),
      _city VARCHAR(255),
      _state VARCHAR(255),
      _zip VARCHAR(255)
      ) RETURNS tinyint(1)
      DETERMINISTIC
      SQL SECURITY INVOKER
  BEGIN
      
      DECLARE _cur_address1 VARCHAR(255);
      DECLARE _cur_address2 VARCHAR(255);
      DECLARE _cur_city VARCHAR(255);
      DECLARE _cur_state VARCHAR(255);
      DECLARE _cur_zip VARCHAR(255);
      DECLARE _is_ok TINYINT(1);
      DECLARE CONTINUE HANDLER FOR NOT FOUND BEGIN SET _is_ok = NULL; END;
      
      SELECT
          property_address.address_1,
          property_address.address_2,
          property_address.city,
          property_address.state_abrv,
          property_address.zip_id
      INTO 
          _cur_address1,
          _cur_address2,
          _cur_city,
          _cur_state,
          _cur_zip
      FROM property_address WHERE property_address.loan_id = _loan_id;
      
      SELECT  IF(LOWER(TRIM(BOTH FROM _cur_address1)) = LOWER(TRIM(BOTH FROM _address1)), 0, 1) +
          IF(LOWER(TRIM(BOTH FROM _cur_address2)) = LOWER(TRIM(BOTH FROM _address2)), 0, 1) +
          IF(LOWER(TRIM(BOTH FROM _cur_city)) = LOWER(TRIM(BOTH FROM _city)), 0, 1) +
          IF(LOWER(TRIM(BOTH FROM _cur_state)) = LOWER(TRIM(BOTH FROM _state)), 0, 1) +
          IF(LOWER(TRIM(BOTH FROM _cur_zip)) = LOWER(TRIM(BOTH FROM _zip)), 0, 1)
      INTO _is_ok;
      
      RETURN _is_ok;
      
  END$$
  </code></pre>
  <p>EDIT: additional fun details:</p>
  <p>These work:</p>
  <ul>
  <li><code>SHOW CREATE FUNCTION dbname.check_address;</code></li>
  <li><code>SHOW CREATE FUNCTION dbname.`check_address`;</code></li>
  <li><code>SHOW CREATE FUNCTION `dbname`.check_address;</code></li>
  </ul>
  <p>This doesn't:</p>
  <ul>
  <li><code>SHOW CREATE FUNCTION `dbname`.`check_address`;</code></li>
  </ul>
  <p>Output of <code>mysql --version</code> (yes, it's old -- not under my control):</p>
  <pre><code>mysql  Ver 14.14 Distrib 5.6.35-80.0, for Linux (x86_64) using  5.1
  </code></pre>