~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/rpl_rli.cc

  • Committer: Brian Aker
  • Date: 2008-07-18 22:05:16 UTC
  • Revision ID: brian@tangent.org-20080718220516-dzyjle0iqqjssphx
Dead debug code removal (and a compatible "never used") bit in the
optimizer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include <drizzled/server_includes.h>
 
16
#include "mysql_priv.h"
17
17
 
18
18
#include "rpl_mi.h"
19
19
#include "rpl_rli.h"
 
20
#include <my_dir.h>
20
21
#include "sql_repl.h"  // For check_binlog_magic
21
22
#include "rpl_utility.h"
22
23
 
23
 
#include <libdrizzle/gettext.h>
24
 
 
25
24
static int32_t count_relay_log_space(Relay_log_info* rli);
26
25
 
27
26
// Defined in slave.cc
49
48
  group_relay_log_name[0]= event_relay_log_name[0]=
50
49
    group_master_log_name[0]= 0;
51
50
  until_log_name[0]= ign_master_log_name_end[0]= 0;
52
 
  memset(&info_file, 0, sizeof(info_file));
53
 
  memset(&cache_buf, 0, sizeof(cache_buf));
 
51
  bzero((char*) &info_file, sizeof(info_file));
 
52
  bzero((char*) &cache_buf, sizeof(cache_buf));
54
53
  cached_charset_invalidate();
55
54
  pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
56
55
  pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
131
130
        instead require a name. But as we don't want to break many existing
132
131
        setups, we only give warning, not error.
133
132
      */
134
 
      sql_print_warning(_("Neither --relay-log nor --relay-log-index were used;"
 
133
      sql_print_warning("Neither --relay-log nor --relay-log-index were used;"
135
134
                        " so replication "
136
135
                        "may break when this MySQL server acts as a "
137
136
                        "slave and has his hostname changed!! Please "
138
 
                        "use '--relay-log=%s' to avoid this problem."), ln);
 
137
                        "use '--relay-log=%s' to avoid this problem.", ln);
139
138
      name_warning_sent= 1;
140
139
    }
141
140
    /*
148
147
                            max_binlog_size), 1))
149
148
    {
150
149
      pthread_mutex_unlock(&rli->data_lock);
151
 
      sql_print_error(_("Failed in open_log() called from "
152
 
                        "init_relay_log_info()"));
 
150
      sql_print_error("Failed in open_log() called from init_relay_log_info()");
153
151
      return(1);
154
152
    }
155
153
  }
165
163
      my_close(info_fd, MYF(MY_WME));
166
164
    if ((info_fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
167
165
    {
168
 
      sql_print_error(_("Failed to create a new relay log info file "
169
 
                        "( file '%s', errno %d)"), fname, my_errno);
 
166
      sql_print_error("Failed to create a new relay log info file (\
 
167
file '%s', errno %d)", fname, my_errno);
170
168
      msg= current_thd->main_da.message();
171
169
      goto err;
172
170
    }
173
171
    if (init_io_cache(&rli->info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0,
174
172
                      MYF(MY_WME)))
175
173
    {
176
 
      sql_print_error(_("Failed to create a cache on relay log info file '%s'"),
 
174
      sql_print_error("Failed to create a cache on relay log info file '%s'",
177
175
                      fname);
178
176
      msg= current_thd->main_da.message();
179
177
      goto err;
180
178
    }
181
179
 
182
180
    /* Init relay log with first entry in the relay index file */
183
 
    if (init_relay_log_pos(rli,NULL,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
 
181
    if (init_relay_log_pos(rli,NullS,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
184
182
                           &msg, 0))
185
183
    {
186
 
      sql_print_error(_("Failed to open the relay log 'FIRST' (relay_log_pos 4)"));
 
184
      sql_print_error("Failed to open the relay log 'FIRST' (relay_log_pos 4)");
187
185
      goto err;
188
186
    }
189
187
    rli->group_master_log_name[0]= 0;
199
197
      int32_t error=0;
200
198
      if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
201
199
      {
202
 
        sql_print_error(_("Failed to open the existing relay log info "
203
 
                          "file '%s' (errno %d)"),
 
200
        sql_print_error("\
 
201
Failed to open the existing relay log info file '%s' (errno %d)",
204
202
                        fname, my_errno);
205
203
        error= 1;
206
204
      }
207
205
      else if (init_io_cache(&rli->info_file, info_fd,
208
206
                             IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
209
207
      {
210
 
        sql_print_error(_("Failed to create a cache on relay log info "
211
 
                          "file '%s'"),
 
208
        sql_print_error("Failed to create a cache on relay log info file '%s'",
212
209
                        fname);
213
210
        error= 1;
214
211
      }
250
247
                           &msg, 0))
251
248
    {
252
249
      char llbuf[22];
253
 
      sql_print_error(_("Failed to open the relay log '%s' (relay_log_pos %s)"),
 
250
      sql_print_error("Failed to open the relay log '%s' (relay_log_pos %s)",
254
251
                      rli->group_relay_log_name,
255
252
                      llstr(rli->group_relay_log_pos, llbuf));
256
253
      goto err;
265
262
  */
266
263
  reinit_io_cache(&rli->info_file, WRITE_CACHE,0L,0,1);
267
264
  if ((error= flush_relay_log_info(rli)))
268
 
    sql_print_error(_("Failed to flush relay log info file"));
 
265
    sql_print_error("Failed to flush relay log info file");
269
266
  if (count_relay_log_space(rli))
270
267
  {
271
 
    msg=_("Error counting relay log space");
 
268
    msg="Error counting relay log space";
272
269
    goto err;
273
270
  }
274
271
  rli->inited= 1;
292
289
  struct stat s;
293
290
  if (stat(linfo->log_file_name,&s))
294
291
  {
295
 
    sql_print_error(_("log %s listed in the index, but failed to stat"),
 
292
    sql_print_error("log %s listed in the index, but failed to stat",
296
293
                    linfo->log_file_name);
297
294
    return(1);
298
295
  }
305
302
{
306
303
  LOG_INFO linfo;
307
304
  rli->log_space_total= 0;
308
 
  if (rli->relay_log.find_log_pos(&linfo, NULL, 1))
 
305
  if (rli->relay_log.find_log_pos(&linfo, NullS, 1))
309
306
  {
310
 
    sql_print_error(_("Could not find first log while counting relay "
311
 
                      "log space"));
 
307
    sql_print_error("Could not find first log while counting relay log space");
312
308
    return(1);
313
309
  }
314
310
  do
420
416
    Test to see if the previous run was with the skip of purging
421
417
    If yes, we do not purge when we restart
422
418
  */
423
 
  if (rli->relay_log.find_log_pos(&rli->linfo, NULL, 1))
 
419
  if (rli->relay_log.find_log_pos(&rli->linfo, NullS, 1))
424
420
  {
425
421
    *errmsg="Could not find first log during relay log initialization";
426
422
    goto err;
609
605
  uint32_t log_name_extension;
610
606
  char log_name_tmp[FN_REFLEN]; //make a char[] from String
611
607
 
612
 
  strmake(log_name_tmp, log_name->ptr(), cmin(log_name->length(), (uint32_t)FN_REFLEN-1));
 
608
  strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
613
609
 
614
610
  char *p= fn_ext(log_name_tmp);
615
611
  char *p_end;
619
615
    goto err;
620
616
  }
621
617
  // Convert 0-3 to 4
622
 
  log_pos= cmax(log_pos, (int64_t)BIN_LOG_HEADER_SIZE);
 
618
  log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
623
619
  /* p points to '.' */
624
620
  log_name_extension= strtoul(++p, &p_end, 10);
625
621
  /*
782
778
 
783
779
void Relay_log_info::close_temporary_tables()
784
780
{
785
 
  Table *table,*next;
 
781
  TABLE *table,*next;
786
782
 
787
783
  for (table=save_temporary_tables ; table ; table=next)
788
784
  {
964
960
      else
965
961
      {
966
962
        /* Probably error so we aborting */
967
 
        sql_print_error(_("Slave SQL thread is stopped because UNTIL "
968
 
                          "condition is bad."));
 
963
        sql_print_error("Slave SQL thread is stopped because UNTIL "
 
964
                        "condition is bad.");
969
965
        return(true);
970
966
      }
971
967
    }
982
978
void Relay_log_info::cached_charset_invalidate()
983
979
{
984
980
  /* Full of zeroes means uninitialized. */
985
 
  memset(cached_charset, 0, sizeof(cached_charset));
 
981
  bzero(cached_charset, sizeof(cached_charset));
986
982
  return;
987
983
}
988
984
 
989
985
 
990
986
bool Relay_log_info::cached_charset_compare(char *charset) const
991
987
{
992
 
  if (memcmp(cached_charset, charset, sizeof(cached_charset)))
 
988
  if (bcmp((uchar*) cached_charset, (uchar*) charset,
 
989
           sizeof(cached_charset)))
993
990
  {
994
991
    memcpy(const_cast<char*>(cached_charset), charset, sizeof(cached_charset));
995
992
    return(1);
1046
1043
  }
1047
1044
}
1048
1045
 
 
1046
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1049
1047
void Relay_log_info::cleanup_context(THD *thd, bool error)
1050
1048
{
1051
1049
  assert(sql_thd == thd);
1083
1081
{
1084
1082
  while (tables_to_lock)
1085
1083
  {
1086
 
    unsigned char* to_free= reinterpret_cast<unsigned char*>(tables_to_lock);
 
1084
    uchar* to_free= reinterpret_cast<uchar*>(tables_to_lock);
1087
1085
    if (tables_to_lock->m_tabledef_valid)
1088
1086
    {
1089
1087
      tables_to_lock->m_tabledef.table_def::~table_def();
1090
1088
      tables_to_lock->m_tabledef_valid= false;
1091
1089
    }
1092
1090
    tables_to_lock=
1093
 
      static_cast<RPL_TableList*>(tables_to_lock->next_global);
 
1091
      static_cast<RPL_TABLE_LIST*>(tables_to_lock->next_global);
1094
1092
    tables_to_lock_count--;
1095
 
    free(to_free);
 
1093
    my_free(to_free, MYF(MY_WME));
1096
1094
  }
1097
1095
  assert(tables_to_lock == NULL && tables_to_lock_count == 0);
1098
1096
}
 
1097
 
 
1098
#endif