~mathiaz/ubuntu/lucid/mysql-dfsg-5.1/zap-bug-552053

« back to all changes in this revision

Viewing changes to sql/log_event.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (1.1.2 upstream) (0.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090625125545-m8ogs96zzsri74xe
Tags: 5.1.34-1ubuntu1
* Merge from debian experimental (and 5.0 from main), remaining changes:
  - debian/mysql-server-5.1.config:
    + ask for MySQL root password at priority high instead of medium so
      that the password prompt is seen on a default install. (LP: #319843)
    + don't ask for root password when upgrading from a 5.0 install.
  - debian/control:
    + Make libmysqlclient16-dev a transitional package depending on
      libmysqlclient-dev.
    + Make libmysqlclient-dev conflict with libmysqlclient15-dev.
    + Don't build mysql-server, mysql-client, mysql-common and
      libmysqlclient15-dev binary packages since they're still provided
      by mysql-dfsg-5.0.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in
      a full MTA on all installs of mysql-server. (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
    + install mysql-test and sql-bench to /usr/share/mysql/ rather than
      /usr/.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    - debian/apparmor-profile: apparmor profile.
    - debian/rules, debian/mysql-server-5.0.files: install apparmor profile.
    - debian/mysql-server-5.0.dirs: add etc/apparmor.d/force-complain
    - debian/mysql-server-5.0.postrm: remove symlink in force-complain/ on
      purge.
    - debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    - debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    - debian/mysql-server-5.1.postinst: reload apparmor profiles.
  - debian/additions/my.cnf: remove language option. Error message files are
    located in a different directory in MySQL 5.0. Setting the language
    option to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1
    use a default value that works. (LP: #316974)
  - debian/mysql-server-5.1.mysql.init:
    + Clearly indicate that we do not support running multiple instances
      of mysqld by duplicating the init script.
      (closes: #314785, #324834, #435165, #444216)
    + Properly parameterize all existing references to the mysql config
      file (/etc/mysql/my.cnf).
  - debian/mysql-server-5.0.postinst: Clear out the second password
    when setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package.
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - Don't package sql-bench and mysql-test file.
* Dropped changes:
  - debian/patches/92_ssl_test_cert.dpatch: certificate expiration in
    test suite (LP: #323755). Included upstream.
* Dropped from 5.0:
  - apparmor profile:
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6. All version
      of apparmor-profile (>hardy) are higher than this version.
    - debian/mysql-server-5.0.preinst: create symlink for force-complain/
      on pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where the profile
      doesn't exist. Support for pre-hardy upgrades is no longer needed.
* debian/mysql-server-5.1.postinst: fix debian-sys-maint user creation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
 
55
55
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
 
56
static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD* thd);
 
57
 
56
58
static const char *HA_ERR(int i)
57
59
{
58
60
  switch (i) {
352
354
                                  int event_server_id, const char *ext)
353
355
{
354
356
  char *res;
355
 
  fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
 
357
  fn_format(buf,PREFIX_SQL_LOAD,slave_load_tmpdir, "", MY_UNPACK_FILENAME);
356
358
  to_unix_path(buf);
357
359
 
358
360
  buf = strend(buf);
380
382
  uint i;
381
383
  char fname[FN_REFLEN], prefbuf[31], *p;
382
384
 
383
 
  if (!(dirp=my_dir(slave_load_tmpdir,MYF(MY_WME))))
 
385
  if (!(dirp=my_dir(slave_load_tmpdir,MYF(0))))
384
386
    return;
385
387
 
386
388
  /* 
391
393
     we cannot meet Start_log event in the middle of events from one 
392
394
     LOAD DATA.
393
395
  */
394
 
  p= strmake(prefbuf, STRING_WITH_LEN("SQL_LOAD-"));
 
396
  p= strmake(prefbuf, STRING_WITH_LEN(PREFIX_SQL_LOAD));
395
397
  p= int10_to_str(::server_id, p, 10);
396
398
  *(p++)= '-';
397
399
  *p= 0;
810
812
  if (is_artificial_event())
811
813
  {
812
814
    /*
813
 
      We should not do any cleanup on slave when reading this. We
814
 
      mark this by setting log_pos to 0.  Start_log_event_v3() will
815
 
      detect this on reading and set artificial_event=1 for the event.
 
815
      Artificial events are automatically generated and do not exist
 
816
      in master's binary log, so log_pos should be set to 0.
816
817
    */
817
818
    log_pos= 0;
818
819
  }
1257
1258
 
1258
1259
  my_b_printf(file, "#");
1259
1260
  print_timestamp(file);
1260
 
  my_b_printf(file, " server id %d  end_log_pos %s ", server_id,
 
1261
  my_b_printf(file, " server id %lu  end_log_pos %s ", (ulong) server_id,
1261
1262
              llstr(log_pos,llbuff));
1262
1263
 
1263
1264
  /* mysqlbinlog --hexdump */
1279
1280
      char emit_buf[256];               // Enough for storing one line
1280
1281
      my_b_printf(file, "# Position  Timestamp   Type   Master ID        "
1281
1282
                  "Size      Master Pos    Flags \n");
1282
 
      int const bytes_written=
 
1283
      size_t const bytes_written=
1283
1284
        my_snprintf(emit_buf, sizeof(emit_buf),
1284
1285
                    "# %8.8lx %02x %02x %02x %02x   %02x   "
1285
1286
                    "%02x %02x %02x %02x   %02x %02x %02x %02x   "
1288
1289
                    ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6],
1289
1290
                    ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13],
1290
1291
                    ptr[14], ptr[15], ptr[16], ptr[17], ptr[18]);
1291
 
      DBUG_ASSERT(bytes_written >= 0);
1292
1292
      DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
1293
1293
      my_b_write(file, (uchar*) emit_buf, bytes_written);
1294
1294
      ptr += LOG_EVENT_MINIMAL_HEADER_LEN;
1314
1314
          TODO: Rewrite my_b_printf() to support full printf() syntax.
1315
1315
         */
1316
1316
        char emit_buf[256];
1317
 
        int const bytes_written=
 
1317
        size_t const bytes_written=
1318
1318
          my_snprintf(emit_buf, sizeof(emit_buf),
1319
1319
                      "# %8.8lx %-48.48s |%16s|\n",
1320
1320
                      (unsigned long) (hexdump_from + (i & 0xfffffff0)),
1321
1321
                      hex_string, char_string);
1322
 
        DBUG_ASSERT(bytes_written >= 0);
1323
1322
        DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
1324
1323
        my_b_write(file, (uchar*) emit_buf, bytes_written);
1325
1324
        hex_string[0]= 0;
1334
1333
    if (hex_string[0])
1335
1334
    {
1336
1335
      char emit_buf[256];
1337
 
      int const bytes_written=
 
1336
      size_t const bytes_written=
1338
1337
        my_snprintf(emit_buf, sizeof(emit_buf),
1339
1338
                    "# %8.8lx %-48.48s |%s|\n",
1340
1339
                    (unsigned long) (hexdump_from + (i & 0xfffffff0)),
1341
1340
                    hex_string, char_string);
1342
 
      DBUG_ASSERT(bytes_written >= 0);
1343
1341
      DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
1344
1342
      my_b_write(file, (uchar*) emit_buf, bytes_written);
1345
1343
    }
1627
1625
 
1628
1626
  case MYSQL_TYPE_DATETIME:
1629
1627
    {
1630
 
      uint d, t;
 
1628
      size_t d, t;
1631
1629
      uint64 i64= uint8korr(ptr); /* YYYYMMDDhhmmss */
1632
1630
      d= i64 / 1000000;
1633
1631
      t= i64 % 1000000;
2724
2722
      bool need_comma= 0;
2725
2723
      my_b_printf(file, "SET ");
2726
2724
      print_set_option(file, tmp, OPTION_NO_FOREIGN_KEY_CHECKS, ~flags2,
2727
 
                   "@@session.foreign_key_checks", &need_comma);
 
2725
                       "@@session.foreign_key_checks", &need_comma);
2728
2726
      print_set_option(file, tmp, OPTION_AUTO_IS_NULL, flags2,
2729
 
                   "@@session.sql_auto_is_null", &need_comma);
 
2727
                       "@@session.sql_auto_is_null", &need_comma);
2730
2728
      print_set_option(file, tmp, OPTION_RELAXED_UNIQUE_CHECKS, ~flags2,
2731
 
                   "@@session.unique_checks", &need_comma);
 
2729
                       "@@session.unique_checks", &need_comma);
 
2730
      print_set_option(file, tmp, OPTION_NOT_AUTOCOMMIT, ~flags2,
 
2731
                       "@@session.autocommit", &need_comma);
2732
2732
      my_b_printf(file,"%s\n", print_event_info->delimiter);
2733
2733
      print_event_info->flags2= flags2;
2734
2734
    }
2893
2893
  DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos));
2894
2894
 
2895
2895
  clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
2896
 
  const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
 
2896
  if (strcmp("COMMIT", query) == 0 && rli->tables_to_lock)
 
2897
  {
 
2898
    /*
 
2899
      Cleaning-up the last statement context:
 
2900
      the terminal event of the current statement flagged with
 
2901
      STMT_END_F got filtered out in ndb circular replication.
 
2902
    */
 
2903
    int error;
 
2904
    char llbuff[22];
 
2905
    if ((error= rows_event_stmt_cleanup(const_cast<Relay_log_info*>(rli), thd)))
 
2906
    {
 
2907
      const_cast<Relay_log_info*>(rli)->report(ERROR_LEVEL, error,
 
2908
                  "Error in cleaning up after an event preceeding the commit; "
 
2909
                  "the group log file/position: %s %s",
 
2910
                  const_cast<Relay_log_info*>(rli)->group_master_log_name,
 
2911
                  llstr(const_cast<Relay_log_info*>(rli)->group_master_log_pos,
 
2912
                        llbuff));
 
2913
    }
 
2914
    /*
 
2915
      Executing a part of rli->stmt_done() logics that does not deal
 
2916
      with group position change. The part is redundant now but is 
 
2917
      future-change-proof addon, e.g if COMMIT handling will start checking
 
2918
      invariants like IN_STMT flag must be off at committing the transaction.
 
2919
    */
 
2920
    const_cast<Relay_log_info*>(rli)->inc_event_relay_log_pos();
 
2921
    const_cast<Relay_log_info*>(rli)->clear_flag(Relay_log_info::IN_STMT);
 
2922
  }
 
2923
  else
 
2924
  {
 
2925
    const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
 
2926
  }
2897
2927
 
2898
2928
  /*
2899
2929
    Note:   We do not need to execute reset_one_shot_variables() if this
3196
3226
#ifndef MYSQL_CLIENT
3197
3227
Start_log_event_v3::Start_log_event_v3()
3198
3228
  :Log_event(), created(0), binlog_version(BINLOG_VERSION),
3199
 
   artificial_event(0), dont_set_created(0)
 
3229
   dont_set_created(0)
3200
3230
{
3201
3231
  memcpy(server_version, ::server_version, ST_SERVER_VER_LEN);
3202
3232
}
3244
3274
      my_b_printf(&cache, "# Warning: this binlog was not closed properly. "
3245
3275
                  "Most probably mysqld crashed writing it.\n");
3246
3276
  }
3247
 
  if (!artificial_event && created)
 
3277
  if (!is_artificial_event() && created)
3248
3278
  {
3249
3279
#ifdef WHEN_WE_HAVE_THE_RESET_CONNECTION_SQL_COMMAND
3250
3280
    /*
3287
3317
  // prevent overrun if log is corrupted on disk
3288
3318
  server_version[ST_SERVER_VER_LEN-1]= 0;
3289
3319
  created= uint4korr(buf+ST_CREATED_OFFSET);
3290
 
  /* We use log_pos to mark if this was an artificial event or not */
3291
 
  artificial_event= (log_pos == 0);
3292
3320
  dont_set_created= 1;
3293
3321
}
3294
3322
 
3730
3758
    original place when it comes to us; we'll know this by checking
3731
3759
    log_pos ("artificial" events have log_pos == 0).
3732
3760
  */
3733
 
  if (!artificial_event && created && thd->transaction.all.ha_list)
 
3761
  if (!is_artificial_event() && created && thd->transaction.all.ha_list)
3734
3762
  {
3735
3763
    /* This is not an error (XA is safe), just an information */
3736
3764
    rli->report(INFORMATION_LEVEL, 0,
4167
4195
  table_name  = fields + field_block_len;
4168
4196
  db = table_name + table_name_len + 1;
4169
4197
  fname = db + db_len + 1;
4170
 
  fname_len = strlen(fname);
 
4198
  fname_len = (uint) strlen(fname);
4171
4199
  // null termination is accomplished by the caller doing buf[event_len]=0
4172
4200
 
4173
4201
  DBUG_RETURN(0);
4667
4695
#endif
4668
4696
  if (flags & DUP_NAME)
4669
4697
    new_log_ident= my_strndup(new_log_ident_arg, ident_len, MYF(MY_WME));
 
4698
  if (flags & RELAY_LOG)
 
4699
    set_relay_log_event();
4670
4700
  DBUG_VOID_RETURN;
4671
4701
}
4672
4702
#endif
4738
4768
  DBUG_PRINT("info", ("new_log_ident: %s", this->new_log_ident));
4739
4769
  DBUG_PRINT("info", ("pos: %s", llstr(this->pos, buf)));
4740
4770
 
4741
 
  pthread_mutex_lock(&rli->data_lock);
4742
 
  rli->event_relay_log_pos= my_b_tell(rli->cur_log);
4743
4771
  /*
4744
4772
    If we are in a transaction or in a group: the only normal case is
4745
4773
    when the I/O thread was copying a big transaction, then it was
4757
4785
    relay log, which shall not change the group positions.
4758
4786
  */
4759
4787
  if ((server_id != ::server_id || rli->replicate_same_server_id) &&
 
4788
      !is_relay_log_event() &&
4760
4789
      !rli->is_in_group())
4761
4790
  {
 
4791
    pthread_mutex_lock(&rli->data_lock);
4762
4792
    DBUG_PRINT("info", ("old group_master_log_name: '%s'  "
4763
4793
                        "old group_master_log_pos: %lu",
4764
4794
                        rli->group_master_log_name,
4765
4795
                        (ulong) rli->group_master_log_pos));
4766
4796
    memcpy(rli->group_master_log_name, new_log_ident, ident_len+1);
4767
4797
    rli->notify_group_master_log_name_update();
4768
 
    rli->group_master_log_pos= pos;
4769
 
    strmake(rli->group_relay_log_name, rli->event_relay_log_name,
4770
 
            sizeof(rli->group_relay_log_name) - 1);
4771
 
    rli->notify_group_relay_log_name_update();
4772
 
    rli->group_relay_log_pos= rli->event_relay_log_pos;
 
4798
    rli->inc_group_relay_log_pos(pos, TRUE /* skip_lock */);
4773
4799
    DBUG_PRINT("info", ("new group_master_log_name: '%s'  "
4774
4800
                        "new group_master_log_pos: %lu",
4775
4801
                        rli->group_master_log_name,
4776
4802
                        (ulong) rli->group_master_log_pos));
 
4803
    pthread_mutex_unlock(&rli->data_lock);
 
4804
    flush_relay_log_info(rli);
 
4805
    
4777
4806
    /*
4778
4807
      Reset thd->options and sql_mode etc, because this could be the signal of
4779
4808
      a master's downgrade from 5.0 to 4.0.
4787
4816
    thd->variables.auto_increment_increment=
4788
4817
      thd->variables.auto_increment_offset= 1;
4789
4818
  }
4790
 
  pthread_mutex_unlock(&rli->data_lock);
4791
 
  pthread_cond_broadcast(&rli->data_cond);
4792
 
  flush_relay_log_info(rli);
 
4819
  else
 
4820
    rli->inc_event_relay_log_pos();
 
4821
 
4793
4822
 
4794
4823
  DBUG_RETURN(0);
4795
4824
}
5665
5694
  master_pos = uint8korr(mem_pool + SL_MASTER_POS_OFFSET);
5666
5695
  master_port = uint2korr(mem_pool + SL_MASTER_PORT_OFFSET);
5667
5696
  master_host = mem_pool + SL_MASTER_HOST_OFFSET;
5668
 
  master_host_len = strlen(master_host);
 
5697
  master_host_len = (uint) strlen(master_host);
5669
5698
  // safety
5670
5699
  master_log = master_host + master_host_len + 1;
5671
5700
  if (master_log > mem_pool + data_size)
5673
5702
    master_host = 0;
5674
5703
    return;
5675
5704
  }
5676
 
  master_log_len = strlen(master_log);
 
5705
  master_log_len = (uint) strlen(master_log);
5677
5706
}
5678
5707
 
5679
5708
 
5945
5974
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
5946
5975
 
5947
5976
 
5948
 
/*
 
5977
/**
5949
5978
  Create_file_log_event::do_apply_event()
 
5979
  Constructor for Create_file_log_event to intantiate an event
 
5980
  from the relay log on the slave.
 
5981
 
 
5982
  @retval
 
5983
    0           Success
 
5984
  @retval
 
5985
    1           Failure
5950
5986
*/
5951
5987
 
5952
5988
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
6015
6051
  if (fd >= 0)
6016
6052
    my_close(fd, MYF(0));
6017
6053
  thd_proc_info(thd, 0);
6018
 
  return error == 0;
 
6054
  return error != 0;
6019
6055
}
6020
6056
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
6021
6057
 
6139
6175
  thd_proc_info(thd, proc_info);
6140
6176
  if (get_create_or_append())
6141
6177
  {
 
6178
    /*
 
6179
      Usually lex_start() is called by mysql_parse(), but we need it here
 
6180
      as the present method does not call mysql_parse().
 
6181
    */
 
6182
    lex_start(thd);
 
6183
    mysql_reset_thd_for_next_command(thd);
6142
6184
    my_delete(fname, MYF(0)); // old copy may exist already
6143
6185
    if ((fd= my_create(fname, CREATE_MODE,
6144
6186
                       O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
6158
6200
                get_type_str(), fname);
6159
6201
    goto err;
6160
6202
  }
 
6203
 
 
6204
  DBUG_EXECUTE_IF("remove_slave_load_file_before_write", 
 
6205
                  my_close(fd,MYF(0)); fd= -1; my_delete(fname, MYF(0)););
 
6206
 
6161
6207
  if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))
6162
6208
  {
6163
6209
    rli->report(ERROR_LEVEL, my_errno,
6579
6625
    my_b_printf(&cache, "\'");
6580
6626
    if (dup_handling == LOAD_DUP_REPLACE)
6581
6627
      my_b_printf(&cache, " REPLACE");
6582
 
    my_b_printf(&cache, " INTO");
 
6628
    my_b_printf(&cache, " INTO ");
6583
6629
    my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end);
6584
6630
    my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);
6585
6631
  }
6660
6706
    /* Ordinary load data */
6661
6707
    break;
6662
6708
  }
6663
 
  p= strmake(p, STRING_WITH_LEN(" INTO"));
 
6709
  p= strmake(p, STRING_WITH_LEN(" INTO "));
6664
6710
  p= strmake(p, query+fn_pos_end, q_len-fn_pos_end);
6665
6711
 
6666
6712
  error= Query_log_event::do_apply_event(rli, buf, p-buf);
6947
6993
{
6948
6994
  int const type_code= get_type_code();
6949
6995
 
6950
 
  uchar buf[sizeof(m_width)+1];
6951
 
  uchar *end= net_store_length(buf, (m_width + 7) / 8);
 
6996
  uchar buf[sizeof(m_width) + 1];
 
6997
  uchar *end= net_store_length(buf, m_width);
6952
6998
 
6953
6999
  DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
6954
7000
                  return 6 + no_bytes_in_map(&m_cols) + (end - buf) +
6956
7002
                  (m_rows_cur - m_rows_buf););
6957
7003
  int data_size= ROWS_HEADER_LEN;
6958
7004
  data_size+= no_bytes_in_map(&m_cols);
6959
 
  data_size+= end - buf;
 
7005
  data_size+= (uint) (end - buf);
6960
7006
 
6961
7007
  if (type_code == UPDATE_ROWS_EVENT)
6962
7008
    data_size+= no_bytes_in_map(&m_cols_ai);
6963
7009
 
6964
 
  data_size+= (m_rows_cur - m_rows_buf);
 
7010
  data_size+= (uint) (m_rows_cur - m_rows_buf);
6965
7011
  return data_size; 
6966
7012
}
6967
7013
 
7396
7442
    return Log_event::do_shall_skip(rli);
7397
7443
}
7398
7444
 
7399
 
int
7400
 
Rows_log_event::do_update_pos(Relay_log_info *rli)
 
7445
/**
 
7446
   The function is called at Rows_log_event statement commit time,
 
7447
   normally from Rows_log_event::do_update_pos() and possibly from
 
7448
   Query_log_event::do_apply_event() of the COMMIT.
 
7449
   The function commits the last statement for engines, binlog and
 
7450
   releases resources have been allocated for the statement.
 
7451
  
 
7452
   @retval  0         Ok.
 
7453
   @retval  non-zero  Error at the commit.
 
7454
 */
 
7455
 
 
7456
static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD * thd)
7401
7457
{
7402
 
  DBUG_ENTER("Rows_log_event::do_update_pos");
7403
 
  int error= 0;
7404
 
 
7405
 
  DBUG_PRINT("info", ("flags: %s",
7406
 
                      get_flags(STMT_END_F) ? "STMT_END_F " : ""));
7407
 
 
7408
 
  if (get_flags(STMT_END_F))
 
7458
  int error;
7409
7459
  {
7410
7460
    /*
7411
7461
      This is the end of a statement or transaction, so close (and
7447
7497
 
7448
7498
    thd->reset_current_stmt_binlog_row_based();
7449
7499
 
7450
 
    rli->cleanup_context(thd, 0);
7451
 
    if (error == 0)
 
7500
    const_cast<Relay_log_info*>(rli)->cleanup_context(thd, 0);
 
7501
  }
 
7502
  return error;
 
7503
}
 
7504
 
 
7505
/**
 
7506
   The method either increments the relay log position or
 
7507
   commits the current statement and increments the master group 
 
7508
   possition if the event is STMT_END_F flagged and
 
7509
   the statement corresponds to the autocommit query (i.e replicated
 
7510
   without wrapping in BEGIN/COMMIT)
 
7511
 
 
7512
   @retval 0         Success
 
7513
   @retval non-zero  Error in the statement commit
 
7514
 */
 
7515
int
 
7516
Rows_log_event::do_update_pos(Relay_log_info *rli)
 
7517
{
 
7518
  DBUG_ENTER("Rows_log_event::do_update_pos");
 
7519
  int error= 0;
 
7520
 
 
7521
  DBUG_PRINT("info", ("flags: %s",
 
7522
                      get_flags(STMT_END_F) ? "STMT_END_F " : ""));
 
7523
 
 
7524
  if (get_flags(STMT_END_F))
 
7525
  {
 
7526
    if ((error= rows_event_stmt_cleanup(rli, thd)) == 0)
7452
7527
    {
7453
7528
      /*
7454
7529
        Indicate that a statement is finished.
7455
7530
        Step the group log position if we are not in a transaction,
7456
7531
        otherwise increase the event log position.
7457
 
       */
 
7532
      */
7458
7533
      rli->stmt_done(log_pos, when);
7459
7534
 
7460
7535
      /*
7468
7543
      thd->clear_error();
7469
7544
    }
7470
7545
    else
 
7546
    {
7471
7547
      rli->report(ERROR_LEVEL, error,
7472
7548
                  "Error in %s event: commit of row events failed, "
7473
7549
                  "table `%s`.`%s`",
7474
7550
                  get_type_str(), m_table->s->db.str,
7475
7551
                  m_table->s->table_name.str);
 
7552
    }
7476
7553
  }
7477
7554
  else
7478
7555
  {
7506
7583
     Note that this should be the number of *bits*, not the number of
7507
7584
     bytes.
7508
7585
  */
7509
 
  uchar sbuf[sizeof(m_width)];
 
7586
  uchar sbuf[sizeof(m_width) + 1];
7510
7587
  my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf;
7511
7588
  bool res= false;
7512
7589
  uchar *const sbuf_end= net_store_length(sbuf, (size_t) m_width);
7668
7745
    m_null_bits(0),
7669
7746
    m_meta_memory(NULL)
7670
7747
{
 
7748
  uchar cbuf[sizeof(m_colcnt) + 1];
 
7749
  uchar *cbuf_end;
7671
7750
  DBUG_ASSERT(m_table_id != ~0UL);
7672
7751
  /*
7673
7752
    In TABLE_SHARE, "db" and "table_name" are 0-terminated (see this comment in
7684
7763
  DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", m_data_size= 6;);
7685
7764
  m_data_size+= m_dblen + 2;    // Include length and terminating \0
7686
7765
  m_data_size+= m_tbllen + 2;   // Include length and terminating \0
7687
 
  m_data_size+= 1 + m_colcnt;   // COLCNT and column types
 
7766
  cbuf_end= net_store_length(cbuf, (size_t) m_colcnt);
 
7767
  DBUG_ASSERT(static_cast<size_t>(cbuf_end - cbuf) <= sizeof(cbuf));
 
7768
  m_data_size+= (cbuf_end - cbuf) + m_colcnt;   // COLCNT and column types
7688
7769
 
7689
7770
  /* If malloc fails, caught in is_valid() */
7690
7771
  if ((m_memory= (uchar*) my_malloc(m_colcnt, MYF(MY_WME))))
7823
7904
    memcpy(m_coltype, ptr_after_colcnt, m_colcnt);
7824
7905
 
7825
7906
    ptr_after_colcnt= ptr_after_colcnt + m_colcnt;
7826
 
    bytes_read= ptr_after_colcnt - (uchar *)buf;
 
7907
    bytes_read= (uint) (ptr_after_colcnt - (uchar *)buf);
7827
7908
    DBUG_PRINT("info", ("Bytes read: %d.\n", bytes_read));
7828
7909
    if (bytes_read < event_len)
7829
7910
    {
7976
8057
  uchar const dbuf[]= { (uchar) m_dblen };
7977
8058
  uchar const tbuf[]= { (uchar) m_tbllen };
7978
8059
 
7979
 
  uchar cbuf[sizeof(m_colcnt)];
 
8060
  uchar cbuf[sizeof(m_colcnt) + 1];
7980
8061
  uchar *const cbuf_end= net_store_length(cbuf, (size_t) m_colcnt);
7981
8062
  DBUG_ASSERT(static_cast<size_t>(cbuf_end - cbuf) <= sizeof(cbuf));
7982
8063
 
9198
9279
Incident_log_event::write_data_body(IO_CACHE *file)
9199
9280
{
9200
9281
  DBUG_ENTER("Incident_log_event::write_data_body");
9201
 
  DBUG_RETURN(write_str(file, m_message.str, m_message.length));
 
9282
  DBUG_RETURN(write_str(file, m_message.str, (uint) m_message.length));
9202
9283
}
9203
9284
 
9204
9285