~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/rpl_rli.cc

Removed/replaced DBUG symbols and TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "sql_repl.h"  // For check_binlog_magic
22
22
#include "rpl_utility.h"
23
23
 
24
 
static int32_t count_relay_log_space(Relay_log_info* rli);
 
24
static int count_relay_log_space(Relay_log_info* rli);
25
25
 
26
26
// Defined in slave.cc
27
 
int32_t init_intvar_from_file(int32_t* var, IO_CACHE* f, int32_t default_val);
28
 
int32_t init_strvar_from_file(char *var, int32_t max_size, IO_CACHE *f,
 
27
int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
 
28
int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
29
29
                          const char *default_val);
30
30
 
31
31
 
77
77
}
78
78
 
79
79
 
80
 
int32_t init_relay_log_info(Relay_log_info* rli,
 
80
int init_relay_log_info(Relay_log_info* rli,
81
81
                        const char* info_fname)
82
82
{
83
83
  char fname[FN_REFLEN+128];
84
 
  int32_t info_fd;
 
84
  int info_fd;
85
85
  const char* msg = 0;
86
 
  int32_t error = 0;
 
86
  int error = 0;
87
87
  assert(!rli->no_storage);         // Don't init if there is no storage
88
88
 
89
89
  if (rli->inited)                       // Set if this function called
194
194
      reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0);
195
195
    else
196
196
    {
197
 
      int32_t error=0;
 
197
      int error=0;
198
198
      if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
199
199
      {
200
200
        sql_print_error("\
221
221
    }
222
222
 
223
223
    rli->info_fd = info_fd;
224
 
    int32_t relay_log_pos, master_log_pos;
 
224
    int relay_log_pos, master_log_pos;
225
225
    if (init_strvar_from_file(rli->group_relay_log_name,
226
226
                              sizeof(rli->group_relay_log_name),
227
227
                              &rli->info_file, "") ||
253
253
      goto err;
254
254
    }
255
255
  }
 
256
  char llbuf1[22], llbuf2[22];
256
257
  assert(rli->event_relay_log_pos >= BIN_LOG_HEADER_SIZE);
257
258
  assert(my_b_tell(rli->cur_log) == rli->event_relay_log_pos);
258
259
 
284
285
}
285
286
 
286
287
 
287
 
static inline int32_t add_relay_log(Relay_log_info* rli,LOG_INFO* linfo)
 
288
static inline int add_relay_log(Relay_log_info* rli,LOG_INFO* linfo)
288
289
{
289
290
  struct stat s;
290
291
  if (stat(linfo->log_file_name,&s))
298
299
}
299
300
 
300
301
 
301
 
static int32_t count_relay_log_space(Relay_log_info* rli)
 
302
static int count_relay_log_space(Relay_log_info* rli)
302
303
{
303
304
  LOG_INFO linfo;
304
305
  rli->log_space_total= 0;
371
372
    1   error.  errmsg is set to point to the error message
372
373
*/
373
374
 
374
 
int32_t init_relay_log_pos(Relay_log_info* rli,const char* log,
375
 
                       uint64_t pos, bool need_data_lock,
 
375
int init_relay_log_pos(Relay_log_info* rli,const char* log,
 
376
                       ulonglong pos, bool need_data_lock,
376
377
                       const char** errmsg,
377
378
                       bool look_for_description_event)
378
379
{
550
551
    timeout         timeout in seconds before giving up waiting
551
552
 
552
553
  NOTES
553
 
    timeout is int64_t whereas it should be uint32_t ; but this is
 
554
    timeout is longlong whereas it should be ulong ; but this is
554
555
    to catch if the user submitted a negative timeout.
555
556
 
556
557
  RETURN VALUES
563
564
                before reaching the desired log/position
564
565
 */
565
566
 
566
 
int32_t Relay_log_info::wait_for_pos(THD* thd, String* log_name,
567
 
                                    int64_t log_pos,
568
 
                                    int64_t timeout)
 
567
int Relay_log_info::wait_for_pos(THD* thd, String* log_name,
 
568
                                    longlong log_pos,
 
569
                                    longlong timeout)
569
570
{
570
 
  int32_t event_count = 0;
571
 
  uint32_t init_abort_pos_wait;
572
 
  int32_t error=0;
 
571
  int event_count = 0;
 
572
  ulong init_abort_pos_wait;
 
573
  int error=0;
573
574
  struct timespec abstime; // for timeout checking
574
575
  const char *msg;
575
576
 
599
600
  /*
600
601
    We'll need to
601
602
    handle all possible log names comparisons (e.g. 999 vs 1000).
602
 
    We use uint32_t for string->number conversion ; this is no
 
603
    We use ulong for string->number conversion ; this is no
603
604
    stronger limitation than in find_uniq_filename in sql/log.cc
604
605
  */
605
 
  uint32_t log_name_extension;
 
606
  ulong log_name_extension;
606
607
  char log_name_tmp[FN_REFLEN]; //make a char[] from String
607
608
 
608
609
  strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
635
636
         slave_running)
636
637
  {
637
638
    bool pos_reached;
638
 
    int32_t cmp_result= 0;
 
639
    int cmp_result= 0;
639
640
 
640
641
    /*
641
642
      group_master_log_name can be "", if we are just after a fresh
661
662
        if the names do not match up to '.' included, return error
662
663
      */
663
664
      char *q= (char*)(fn_ext(basename)+1);
664
 
      if (strncmp(basename, log_name_tmp, (int32_t)(q-basename)))
 
665
      if (strncmp(basename, log_name_tmp, (int)(q-basename)))
665
666
      {
666
667
        error= -2;
667
668
        break;
668
669
      }
669
670
      // Now compare extensions.
670
671
      char *q_end;
671
 
      uint32_t group_master_log_name_extension= strtoul(q, &q_end, 10);
 
672
      ulong group_master_log_name_extension= strtoul(q, &q_end, 10);
672
673
      if (group_master_log_name_extension < log_name_extension)
673
674
        cmp_result= -1 ;
674
675
      else
675
676
        cmp_result= (group_master_log_name_extension > log_name_extension) ? 1 : 0 ;
676
677
 
677
 
      pos_reached= ((!cmp_result && group_master_log_pos >= (uint64_t)log_pos) ||
 
678
      pos_reached= ((!cmp_result && group_master_log_pos >= (ulonglong)log_pos) ||
678
679
                    cmp_result > 0);
679
680
      if (pos_reached || thd->killed)
680
681
        break;
723
724
}
724
725
 
725
726
 
726
 
void Relay_log_info::inc_group_relay_log_pos(uint64_t log_pos,
 
727
void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
727
728
                                                bool skip_lock)
728
729
{
729
730
  if (!skip_lock)
801
802
    Assumes to have a run lock on rli and that no slave thread are running.
802
803
*/
803
804
 
804
 
int32_t purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
 
805
int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
805
806
                     const char** errmsg)
806
807
{
807
 
  int32_t error=0;
 
808
  int error=0;
808
809
 
809
810
  /*
810
811
    Even if rli->inited==0, we still try to empty rli->master_log_* variables.
915
916
bool Relay_log_info::is_until_satisfied(my_off_t master_beg_pos)
916
917
{
917
918
  const char *log_name;
918
 
  uint64_t log_pos;
 
919
  ulonglong log_pos;
919
920
 
920
921
  assert(until_condition != UNTIL_NONE);
921
922
 
945
946
      const char *basename= log_name + dirname_length(log_name);
946
947
 
947
948
      const char *q= (const char*)(fn_ext(basename)+1);
948
 
      if (strncmp(basename, until_log_name, (int32_t)(q-basename)) == 0)
 
949
      if (strncmp(basename, until_log_name, (int)(q-basename)) == 0)
949
950
      {
950
951
        /* Now compare extensions. */
951
952
        char *q_end;
952
 
        uint32_t log_name_extension= strtoul(q, &q_end, 10);
 
953
        ulong log_name_extension= strtoul(q, &q_end, 10);
953
954
        if (log_name_extension < until_log_name_extension)
954
955
          until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_LESS;
955
956
        else
998
999
void Relay_log_info::stmt_done(my_off_t event_master_log_pos,
999
1000
                                  time_t event_creation_time)
1000
1001
{
1001
 
  extern uint32_t debug_not_change_ts_if_art_event;
 
1002
  extern uint debug_not_change_ts_if_art_event;
1002
1003
  clear_flag(IN_STMT);
1003
1004
 
1004
1005
  /*