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

« back to all changes in this revision

Viewing changes to sql/log_event.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:
585
585
*/
586
586
 
587
587
int
588
 
append_query_string(CHARSET_INFO *csinfo,
 
588
append_query_string(THD *thd, CHARSET_INFO *csinfo,
589
589
                    String const *from, String *to)
590
590
{
591
591
  char *beg, *ptr;
600
600
  else
601
601
  {
602
602
    *ptr++= '\'';
603
 
    ptr+= escape_string_for_mysql(csinfo, ptr, 0,
604
 
                                  from->ptr(), from->length());
605
 
    *ptr++='\'';
 
603
    if (!(thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES))
 
604
    {
 
605
      ptr+= escape_string_for_mysql(csinfo, ptr, 0,
 
606
                                    from->ptr(), from->length());
 
607
    }
 
608
    else
 
609
    {
 
610
      const char *frm_str= from->ptr();
 
611
 
 
612
      for (; frm_str < (from->ptr() + from->length()); frm_str++)
 
613
      {
 
614
        /* Using '' way to represent "'" */
 
615
        if (*frm_str == '\'')
 
616
          *ptr++= *frm_str;
 
617
 
 
618
        *ptr++= *frm_str;
 
619
      }
 
620
    }
 
621
 
 
622
    *ptr++= '\'';
606
623
  }
607
624
  to->length(orig_len + ptr - beg);
608
625
  return 0;
5577
5594
  res= trans_commit(thd); /* Automatically rolls back on error. */
5578
5595
  thd->mdl_context.release_transactional_locks();
5579
5596
 
 
5597
  /*
 
5598
    Increment the global status commit count variable
 
5599
  */
 
5600
  status_var_increment(thd->status_var.com_stat[SQLCOM_COMMIT]);
 
5601
 
5580
5602
  return res;
5581
5603
}
5582
5604
 
7641
7663
    {
7642
7664
      DBUG_PRINT("debug", ("Checking compability of tables to lock - tables_to_lock: %p",
7643
7665
                           rli->tables_to_lock));
 
7666
 
 
7667
      /**
 
7668
        When using RBR and MyISAM MERGE tables the base tables that make
 
7669
        up the MERGE table can be appended to the list of tables to lock.
 
7670
  
 
7671
        Thus, we just check compatibility for those that tables that have
 
7672
        a correspondent table map event (ie, those that are actually going
 
7673
        to be accessed while applying the event). That's why the loop stops
 
7674
        at rli->tables_to_lock_count .
 
7675
 
 
7676
        NOTE: The base tables are added here are removed when 
 
7677
              close_thread_tables is called.
 
7678
       */
7644
7679
      RPL_TABLE_LIST *ptr= rli->tables_to_lock;
7645
 
      for ( ; ptr ; ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global))
 
7680
      for (uint i= 0 ; ptr && (i < rli->tables_to_lock_count);
 
7681
           ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_global), i++)
7646
7682
      {
 
7683
        DBUG_ASSERT(ptr->m_tabledef_valid);
7647
7684
        TABLE *conv_table;
7648
7685
        if (!ptr->m_tabledef.compatible_with(thd, const_cast<Relay_log_info*>(rli),
7649
7686
                                             ptr->table, &conv_table))
7681
7718
      Rows_log_event, we can invalidate the query cache for the
7682
7719
      associated table.
7683
7720
     */
7684
 
    for (TABLE_LIST *ptr= rli->tables_to_lock ; ptr ; ptr= ptr->next_global)
7685
 
    {
 
7721
    TABLE_LIST *ptr= rli->tables_to_lock;
 
7722
    for (uint i=0 ;  ptr && (i < rli->tables_to_lock_count); ptr= ptr->next_global, i++)
7686
7723
      const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
7687
 
    }
 
7724
 
7688
7725
#ifdef HAVE_QUERY_CACHE
7689
7726
    query_cache.invalidate_locked_for_write(rli->tables_to_lock);
7690
7727
#endif
8466
8503
    res= FILTERED_OUT;
8467
8504
  else
8468
8505
  {
8469
 
    for(RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(rli->tables_to_lock);
8470
 
        ptr; 
8471
 
        ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_local))
 
8506
    RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(rli->tables_to_lock);
 
8507
    for(uint i=0 ; ptr && (i< rli->tables_to_lock_count); 
 
8508
        ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_local), i++)
8472
8509
    {
8473
8510
      if (ptr->table_id == table_list->table_id)
8474
8511
      {
8732
8769
{
8733
8770
  int error= 0;
8734
8771
 
 
8772
  /*
 
8773
    Increment the global status insert count variable
 
8774
  */
 
8775
  if (get_flags(STMT_END_F))
 
8776
    status_var_increment(thd->status_var.com_stat[SQLCOM_INSERT]);
 
8777
 
8735
8778
  /**
8736
8779
     todo: to introduce a property for the event (handler?) which forces
8737
8780
     applying the event in the replace (idempotent) fashion.
9665
9708
int 
9666
9709
Delete_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
9667
9710
{
 
9711
  /*
 
9712
    Increment the global status delete count variable
 
9713
   */
 
9714
  if (get_flags(STMT_END_F))
 
9715
    status_var_increment(thd->status_var.com_stat[SQLCOM_DELETE]);
 
9716
 
9668
9717
  if ((m_table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) &&
9669
9718
      m_table->s->primary_key < MAX_KEY)
9670
9719
  {
9794
9843
int 
9795
9844
Update_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
9796
9845
{
 
9846
  /*
 
9847
    Increment the global status update count variable
 
9848
  */
 
9849
  if (get_flags(STMT_END_F))
 
9850
    status_var_increment(thd->status_var.com_stat[SQLCOM_UPDATE]);
 
9851
 
9797
9852
  if (m_table->s->keys > 0)
9798
9853
  {
9799
9854
    // Allocate buffer for key searches