~james-page/ubuntu/precise/mysql-5.5/misc-fixes

« back to all changes in this revision

Viewing changes to sql/sql_base.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-06-11 07:34:33 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120611073433-l9za2ni4ipp848y3
Tags: 5.5.24-0ubuntu0.12.04.1
* SECURITY UPDATE: Update to 5.5.24 to fix security issues (LP: #1011371)
  - http://dev.mysql.com/doc/refman/5.5/en/news-5-5-24.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
5691
5691
        has_write_table_with_auto_increment_and_select(tables))
5692
5692
      thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT);
5693
5693
 
 
5694
    /* 
 
5695
     INSERT...ON DUPLICATE KEY UPDATE on a table with more than one unique keys
 
5696
     can be unsafe.
 
5697
     */
 
5698
    uint unique_keys= 0;
 
5699
    for (TABLE_LIST *query_table= tables; query_table && unique_keys <= 1;
 
5700
         query_table= query_table->next_global)
 
5701
      if(query_table->table)
 
5702
      {
 
5703
        uint keys= query_table->table->s->keys, i= 0;
 
5704
        unique_keys= 0;
 
5705
        for (KEY* keyinfo= query_table->table->s->key_info;
 
5706
             i < keys && unique_keys <= 1; i++, keyinfo++)
 
5707
        {
 
5708
          if (keyinfo->flags & HA_NOSAME)
 
5709
            unique_keys++;
 
5710
        }
 
5711
        if (!query_table->placeholder() &&
 
5712
            query_table->lock_type >= TL_WRITE_ALLOW_WRITE &&
 
5713
            unique_keys > 1 && thd->lex->sql_command == SQLCOM_INSERT &&
 
5714
            /* Duplicate key update is not supported by INSERT DELAYED */
 
5715
            thd->command != COM_DELAYED_INSERT &&
 
5716
            thd->lex->duplicates == DUP_UPDATE)
 
5717
          thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS);
 
5718
      }
 
5719
 
5694
5720
    /* We have to emulate LOCK TABLES if we are statement needs prelocking. */
5695
5721
    if (thd->lex->requires_prelocking())
5696
5722
    {