title: Storage limits of MySQL user-defined variables
body: <p>Under <a href="http://dev.mysql.com/doc/refman/5.5/en/user-variables.html">User-Defined Variables</a>, the MySQL manual documents:</p>
  
  <blockquote>
    <p>User variables can be assigned a value from a limited set of data types: integer, decimal, floating-point, binary or nonbinary string, or <code>NULL</code> value. Assignment of decimal and real values does not preserve the precision or scale of the value. A value of a type other than one of the permissible types is converted to a permissible type. For example, a value having a temporal or spatial data type is converted to a binary string.</p>
    
    <p>If a user variable is assigned a nonbinary (character) string value, it has the same character set and collation as the string. The coercibility of user variables is implicit. (This is the same coercibility as for table column values.)</p>
  </blockquote>
  
  <p>However the manual does not state:</p>
  
  <ul>
  <li><p><strong>the <em>size</em> of supported integers (e.g. 4-byte <code>INT</code>, or 8-byte <code>BIGINT</code>), whether they are signed or unsigned, and whether <code>ZEROFILL</code> is applied (if so, using what display width);</strong></p>
  
  <p><a href="http://sqlfiddle.com/#!2/b6a51/1/1">This sqlfiddle</a> <em>appears</em> to suggest that MySQL 5.5.25 will use up to <code>BIGINT</code>, signed according to the assignment, and will not apply any <code>ZEROFILL</code>.</p></li>
  <li><p><strong>the precision and scale used in fixed- and floating-point values, given that this is not preserved from the assignment; and</strong></p></li>
  <li><p><strong>the maximum length (in characters and/or bytes) of strings.</strong></p>
  
  <p>sqlfiddle is limited by <code>max_allowed_packet</code> of 2<sup>20</sup> bytes (which I can't change): I'd <em>guess</em> that <code>LONGTEXT</code> of 2<sup>32</sup> bytes (4GiB) is supported.</p></li>
  </ul>
  
  <p>What limits can be safely relied upon, especially across different server versions and configurations?</p>