How many bind variables can I use in a SQL query in MySQL 5?

Is there a limit on the number of bind variables that I can use in a query in MySQL 5? I suppose there is, but I cannot find any information in the reference guide or on Google.

The only thing I can find that provides any information is a link to the C API: http://dev.mysql.com/doc/refman/5.0/en/mysql-stmt-bind-result.html

This seems to mean that memory is the only limit, but it seems a little suspicious.

Update : there is a limit!

runner.rb:47: data_replicator.rb:312:in `prepare': Prepared statement contains too many placeholders (Mysql::Error)
        from data_replicator.rb:312:in `set_statement_handle_for'
        from data_replicator.rb:287:in `log_query'
        from data_replicator.rb:221:in `replicate_table'
        from data_replicator.rb:93:in `replicate'
        from data_replicator.rb:20:in `run'

It gives me something better to search!

+5
source share
3 answers
-4

- 16- , specfically: 65 536.

MySQL : SQL/sql_prepare.cc:

static bool init_param_array(Prepared_statement *stmt)
{
  LEX *lex= stmt->lex;
  if ((stmt->param_count= lex->param_list.elements))
  {
    if (stmt->param_count > (uint) UINT_MAX16)
    {
      /* Error code to be defined in 5.0 */
      my_message(ER_PS_MANY_PARAM, ER(ER_PS_MANY_PARAM), MYF(0));
      return TRUE;
    }
+9

MariaDB 5.5 65,535 (2 ^ 16-1), MySQL 5.5.

, , PHP 5.5.12 MySQLi/MySQLND.

+1
source

All Articles