~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/rpl_rli.cc

  • Committer: Monty Taylor
  • Date: 2008-07-09 15:52:52 UTC
  • mto: (77.6.1 glibclient-merge)
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: monty@inaugust.com-20080709155252-lnzmxxje1g40z3a7
Warning fixes. 

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
 
32
32
Relay_log_info::Relay_log_info()
33
33
  :Slave_reporting_capability("SQL"),
34
 
   no_storage(false), replicate_same_server_id(::replicate_same_server_id),
 
34
   no_storage(FALSE), replicate_same_server_id(::replicate_same_server_id),
35
35
   info_fd(-1), cur_log_fd(-1), save_temporary_tables(0),
36
 
#if defined(HAVE_purify) && HAVE_purify
37
 
   is_fake(false),
 
36
#if HAVE_purify
 
37
   is_fake(FALSE),
38
38
#endif
39
39
   cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
40
40
   group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0),
45
45
   tables_to_lock(0), tables_to_lock_count(0),
46
46
   last_event_start_time(0), m_flags(0)
47
47
{
 
48
  DBUG_ENTER("Relay_log_info::Relay_log_info");
 
49
 
48
50
  group_relay_log_name[0]= event_relay_log_name[0]=
49
51
    group_master_log_name[0]= 0;
50
52
  until_log_name[0]= ign_master_log_name_end[0]= 0;
59
61
  pthread_cond_init(&stop_cond, NULL);
60
62
  pthread_cond_init(&log_space_cond, NULL);
61
63
  relay_log.init_pthread_objects();
62
 
  return;
 
64
  DBUG_VOID_RETURN;
63
65
}
64
66
 
65
67
 
66
68
Relay_log_info::~Relay_log_info()
67
69
{
 
70
  DBUG_ENTER("Relay_log_info::~Relay_log_info");
 
71
 
68
72
  pthread_mutex_destroy(&run_lock);
69
73
  pthread_mutex_destroy(&data_lock);
70
74
  pthread_mutex_destroy(&log_space_lock);
73
77
  pthread_cond_destroy(&stop_cond);
74
78
  pthread_cond_destroy(&log_space_cond);
75
79
  relay_log.cleanup();
76
 
  return;
 
80
  DBUG_VOID_RETURN;
77
81
}
78
82
 
79
83
 
80
 
int32_t init_relay_log_info(Relay_log_info* rli,
 
84
int init_relay_log_info(Relay_log_info* rli,
81
85
                        const char* info_fname)
82
86
{
83
87
  char fname[FN_REFLEN+128];
84
 
  int32_t info_fd;
 
88
  int info_fd;
85
89
  const char* msg = 0;
86
 
  int32_t error = 0;
87
 
  assert(!rli->no_storage);         // Don't init if there is no storage
 
90
  int error = 0;
 
91
  DBUG_ENTER("init_relay_log_info");
 
92
  DBUG_ASSERT(!rli->no_storage);         // Don't init if there is no storage
88
93
 
89
94
  if (rli->inited)                       // Set if this function called
90
 
    return(0);
 
95
    DBUG_RETURN(0);
91
96
  fn_format(fname, info_fname, mysql_data_home, "", 4+32);
92
97
  pthread_mutex_lock(&rli->data_lock);
93
98
  info_fd = rli->info_fd;
148
153
    {
149
154
      pthread_mutex_unlock(&rli->data_lock);
150
155
      sql_print_error("Failed in open_log() called from init_relay_log_info()");
151
 
      return(1);
 
156
      DBUG_RETURN(1);
152
157
    }
153
158
  }
154
159
 
194
199
      reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0);
195
200
    else
196
201
    {
197
 
      int32_t error=0;
 
202
      int error=0;
198
203
      if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
199
204
      {
200
205
        sql_print_error("\
216
221
        rli->info_fd= -1;
217
222
        rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
218
223
        pthread_mutex_unlock(&rli->data_lock);
219
 
        return(1);
 
224
        DBUG_RETURN(1);
220
225
      }
221
226
    }
222
227
 
223
228
    rli->info_fd = info_fd;
224
 
    int32_t relay_log_pos, master_log_pos;
 
229
    int relay_log_pos, master_log_pos;
225
230
    if (init_strvar_from_file(rli->group_relay_log_name,
226
231
                              sizeof(rli->group_relay_log_name),
227
232
                              &rli->info_file, "") ||
253
258
      goto err;
254
259
    }
255
260
  }
256
 
  char llbuf1[22], llbuf2[22];
257
 
  assert(rli->event_relay_log_pos >= BIN_LOG_HEADER_SIZE);
258
 
  assert(my_b_tell(rli->cur_log) == rli->event_relay_log_pos);
 
261
 
 
262
#ifndef DBUG_OFF
 
263
  {
 
264
    char llbuf1[22], llbuf2[22];
 
265
    DBUG_PRINT("info", ("my_b_tell(rli->cur_log)=%s rli->event_relay_log_pos=%s",
 
266
                        llstr(my_b_tell(rli->cur_log),llbuf1),
 
267
                        llstr(rli->event_relay_log_pos,llbuf2)));
 
268
    DBUG_ASSERT(rli->event_relay_log_pos >= BIN_LOG_HEADER_SIZE);
 
269
    DBUG_ASSERT(my_b_tell(rli->cur_log) == rli->event_relay_log_pos);
 
270
  }
 
271
#endif
259
272
 
260
273
  /*
261
274
    Now change the cache from READ to WRITE - must do this
271
284
  }
272
285
  rli->inited= 1;
273
286
  pthread_mutex_unlock(&rli->data_lock);
274
 
  return(error);
 
287
  DBUG_RETURN(error);
275
288
 
276
289
err:
277
290
  sql_print_error(msg);
281
294
  rli->info_fd= -1;
282
295
  rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
283
296
  pthread_mutex_unlock(&rli->data_lock);
284
 
  return(1);
 
297
  DBUG_RETURN(1);
285
298
}
286
299
 
287
300
 
288
 
static inline int32_t add_relay_log(Relay_log_info* rli,LOG_INFO* linfo)
 
301
static inline int add_relay_log(Relay_log_info* rli,LOG_INFO* linfo)
289
302
{
290
303
  struct stat s;
 
304
  DBUG_ENTER("add_relay_log");
291
305
  if (stat(linfo->log_file_name,&s))
292
306
  {
293
307
    sql_print_error("log %s listed in the index, but failed to stat",
294
308
                    linfo->log_file_name);
295
 
    return(1);
 
309
    DBUG_RETURN(1);
296
310
  }
297
311
  rli->log_space_total += s.st_size;
298
 
  return(0);
 
312
#ifndef DBUG_OFF
 
313
  char buf[22];
 
314
  DBUG_PRINT("info",("log_space_total: %s", llstr(rli->log_space_total,buf)));
 
315
#endif
 
316
  DBUG_RETURN(0);
299
317
}
300
318
 
301
319
 
302
 
static int32_t count_relay_log_space(Relay_log_info* rli)
 
320
static int count_relay_log_space(Relay_log_info* rli)
303
321
{
304
322
  LOG_INFO linfo;
 
323
  DBUG_ENTER("count_relay_log_space");
305
324
  rli->log_space_total= 0;
306
325
  if (rli->relay_log.find_log_pos(&linfo, NullS, 1))
307
326
  {
308
327
    sql_print_error("Could not find first log while counting relay log space");
309
 
    return(1);
 
328
    DBUG_RETURN(1);
310
329
  }
311
330
  do
312
331
  {
313
332
    if (add_relay_log(rli,&linfo))
314
 
      return(1);
 
333
      DBUG_RETURN(1);
315
334
  } while (!rli->relay_log.find_next_log(&linfo, 1));
316
335
  /*
317
336
     As we have counted everything, including what may have written in a
319
338
     twice.
320
339
  */
321
340
  rli->relay_log.reset_bytes_written();
322
 
  return(0);
 
341
  DBUG_RETURN(0);
323
342
}
324
343
 
325
344
 
333
352
 
334
353
void Relay_log_info::clear_until_condition()
335
354
{
 
355
  DBUG_ENTER("clear_until_condition");
 
356
 
336
357
  until_condition= Relay_log_info::UNTIL_NONE;
337
358
  until_log_name[0]= 0;
338
359
  until_log_pos= 0;
339
 
  return;
 
360
  DBUG_VOID_RETURN;
340
361
}
341
362
 
342
363
 
372
393
    1   error.  errmsg is set to point to the error message
373
394
*/
374
395
 
375
 
int32_t init_relay_log_pos(Relay_log_info* rli,const char* log,
376
 
                       uint64_t pos, bool need_data_lock,
 
396
int init_relay_log_pos(Relay_log_info* rli,const char* log,
 
397
                       ulonglong pos, bool need_data_lock,
377
398
                       const char** errmsg,
378
399
                       bool look_for_description_event)
379
400
{
 
401
  DBUG_ENTER("init_relay_log_pos");
 
402
  DBUG_PRINT("info", ("pos: %lu", (ulong) pos));
 
403
 
380
404
  *errmsg=0;
381
405
  pthread_mutex_t *log_lock=rli->relay_log.get_log_lock();
382
406
 
467
491
        Read the possible Format_description_log_event; if position
468
492
        was 4, no need, it will be read naturally.
469
493
      */
 
494
      DBUG_PRINT("info",("looking for a Format_description_log_event"));
 
495
 
470
496
      if (my_b_tell(rli->cur_log) >= pos)
471
497
        break;
472
498
 
477
503
      if (!(ev=Log_event::read_log_event(rli->cur_log,0,
478
504
                                         rli->relay_log.description_event_for_exec)))
479
505
      {
 
506
        DBUG_PRINT("info",("could not read event, rli->cur_log->error=%d",
 
507
                           rli->cur_log->error));
480
508
        if (rli->cur_log->error) /* not EOF */
481
509
        {
482
510
          *errmsg= "I/O error reading event at position 4";
486
514
      }
487
515
      else if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
488
516
      {
 
517
        DBUG_PRINT("info",("found Format_description_log_event"));
489
518
        delete rli->relay_log.description_event_for_exec;
490
519
        rli->relay_log.description_event_for_exec= (Format_description_log_event*) ev;
491
520
        /*
511
540
      }
512
541
      else
513
542
      {
 
543
        DBUG_PRINT("info",("found event of another type=%d",
 
544
                           ev->get_type_code()));
514
545
        look_for_description_event= (ev->get_type_code() == ROTATE_EVENT);
515
546
        delete ev;
516
547
      }
517
548
    }
518
549
    my_b_seek(rli->cur_log,(off_t)pos);
 
550
#ifndef DBUG_OFF
 
551
  {
 
552
    char llbuf1[22], llbuf2[22];
 
553
    DBUG_PRINT("info", ("my_b_tell(rli->cur_log)=%s rli->event_relay_log_pos=%s",
 
554
                        llstr(my_b_tell(rli->cur_log),llbuf1),
 
555
                        llstr(rli->event_relay_log_pos,llbuf2)));
 
556
  }
 
557
#endif
519
558
 
520
559
  }
521
560
 
535
574
  if (!rli->relay_log.description_event_for_exec->is_valid() && !*errmsg)
536
575
    *errmsg= "Invalid Format_description log event; could be out of memory";
537
576
 
538
 
  return ((*errmsg) ? 1 : 0);
 
577
  DBUG_RETURN ((*errmsg) ? 1 : 0);
539
578
}
540
579
 
541
580
 
551
590
    timeout         timeout in seconds before giving up waiting
552
591
 
553
592
  NOTES
554
 
    timeout is longlong whereas it should be uint32_t ; but this is
 
593
    timeout is longlong whereas it should be ulong ; but this is
555
594
    to catch if the user submitted a negative timeout.
556
595
 
557
596
  RETURN VALUES
564
603
                before reaching the desired log/position
565
604
 */
566
605
 
567
 
int32_t Relay_log_info::wait_for_pos(THD* thd, String* log_name,
 
606
int Relay_log_info::wait_for_pos(THD* thd, String* log_name,
568
607
                                    longlong log_pos,
569
608
                                    longlong timeout)
570
609
{
571
 
  int32_t event_count = 0;
572
 
  uint32_t init_abort_pos_wait;
573
 
  int32_t error=0;
 
610
  int event_count = 0;
 
611
  ulong init_abort_pos_wait;
 
612
  int error=0;
574
613
  struct timespec abstime; // for timeout checking
575
614
  const char *msg;
 
615
  DBUG_ENTER("Relay_log_info::wait_for_pos");
576
616
 
577
617
  if (!inited)
578
 
    return(-2);
 
618
    DBUG_RETURN(-2);
 
619
 
 
620
  DBUG_PRINT("enter",("log_name: '%s'  log_pos: %lu  timeout: %lu",
 
621
                      log_name->c_ptr(), (ulong) log_pos, (ulong) timeout));
579
622
 
580
623
  set_timespec(abstime,timeout);
581
624
  pthread_mutex_lock(&data_lock);
600
643
  /*
601
644
    We'll need to
602
645
    handle all possible log names comparisons (e.g. 999 vs 1000).
603
 
    We use uint32_t for string->number conversion ; this is no
 
646
    We use ulong for string->number conversion ; this is no
604
647
    stronger limitation than in find_uniq_filename in sql/log.cc
605
648
  */
606
 
  uint32_t log_name_extension;
 
649
  ulong log_name_extension;
607
650
  char log_name_tmp[FN_REFLEN]; //make a char[] from String
608
651
 
609
652
  strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
636
679
         slave_running)
637
680
  {
638
681
    bool pos_reached;
639
 
    int32_t cmp_result= 0;
 
682
    int cmp_result= 0;
 
683
 
 
684
    DBUG_PRINT("info",
 
685
               ("init_abort_pos_wait: %ld  abort_pos_wait: %ld",
 
686
                init_abort_pos_wait, abort_pos_wait));
 
687
    DBUG_PRINT("info",("group_master_log_name: '%s'  pos: %lu",
 
688
                       group_master_log_name, (ulong) group_master_log_pos));
640
689
 
641
690
    /*
642
691
      group_master_log_name can be "", if we are just after a fresh
662
711
        if the names do not match up to '.' included, return error
663
712
      */
664
713
      char *q= (char*)(fn_ext(basename)+1);
665
 
      if (strncmp(basename, log_name_tmp, (int32_t)(q-basename)))
 
714
      if (strncmp(basename, log_name_tmp, (int)(q-basename)))
666
715
      {
667
716
        error= -2;
668
717
        break;
669
718
      }
670
719
      // Now compare extensions.
671
720
      char *q_end;
672
 
      uint32_t group_master_log_name_extension= strtoul(q, &q_end, 10);
 
721
      ulong group_master_log_name_extension= strtoul(q, &q_end, 10);
673
722
      if (group_master_log_name_extension < log_name_extension)
674
723
        cmp_result= -1 ;
675
724
      else
676
725
        cmp_result= (group_master_log_name_extension > log_name_extension) ? 1 : 0 ;
677
726
 
678
 
      pos_reached= ((!cmp_result && group_master_log_pos >= (uint64_t)log_pos) ||
 
727
      pos_reached= ((!cmp_result && group_master_log_pos >= (ulonglong)log_pos) ||
679
728
                    cmp_result > 0);
680
729
      if (pos_reached || thd->killed)
681
730
        break;
683
732
 
684
733
    //wait for master update, with optional timeout.
685
734
 
 
735
    DBUG_PRINT("info",("Waiting for master update"));
686
736
    /*
687
737
      We are going to pthread_cond_(timed)wait(); if the SQL thread stops it
688
738
      will wake us up.
704
754
    }
705
755
    else
706
756
      pthread_cond_wait(&data_cond, &data_lock);
 
757
    DBUG_PRINT("info",("Got signal of master update or timed out"));
707
758
    if (error == ETIMEDOUT || error == ETIME)
708
759
    {
709
760
      error= -1;
711
762
    }
712
763
    error=0;
713
764
    event_count++;
 
765
    DBUG_PRINT("info",("Testing if killed or SQL thread not running"));
714
766
  }
715
767
 
716
768
err:
717
769
  thd->exit_cond(msg);
 
770
  DBUG_PRINT("exit",("killed: %d  abort: %d  slave_running: %d \
 
771
improper_arguments: %d  timed_out: %d",
 
772
                     thd->killed_errno(),
 
773
                     (int) (init_abort_pos_wait != abort_pos_wait),
 
774
                     (int) slave_running,
 
775
                     (int) (error == -2),
 
776
                     (int) (error == -1)));
718
777
  if (thd->killed || init_abort_pos_wait != abort_pos_wait ||
719
778
      !slave_running)
720
779
  {
721
780
    error= -2;
722
781
  }
723
 
  return( error ? error : event_count );
 
782
  DBUG_RETURN( error ? error : event_count );
724
783
}
725
784
 
726
785
 
727
 
void Relay_log_info::inc_group_relay_log_pos(uint64_t log_pos,
 
786
void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
728
787
                                                bool skip_lock)
729
788
{
 
789
  DBUG_ENTER("Relay_log_info::inc_group_relay_log_pos");
 
790
 
730
791
  if (!skip_lock)
731
792
    pthread_mutex_lock(&data_lock);
732
793
  inc_event_relay_log_pos();
766
827
    the relay log is not "val".
767
828
    With the end_log_pos solution, we avoid computations involving lengthes.
768
829
  */
 
830
  DBUG_PRINT("info", ("log_pos: %lu  group_master_log_pos: %lu",
 
831
                      (long) log_pos, (long) group_master_log_pos));
769
832
  if (log_pos) // 3.23 binlogs don't have log_posx
770
833
  {
771
834
    group_master_log_pos= log_pos;
773
836
  pthread_cond_broadcast(&data_cond);
774
837
  if (!skip_lock)
775
838
    pthread_mutex_unlock(&data_lock);
776
 
  return;
 
839
  DBUG_VOID_RETURN;
777
840
}
778
841
 
779
842
 
780
843
void Relay_log_info::close_temporary_tables()
781
844
{
782
845
  TABLE *table,*next;
 
846
  DBUG_ENTER("Relay_log_info::close_temporary_tables");
783
847
 
784
848
  for (table=save_temporary_tables ; table ; table=next)
785
849
  {
788
852
      Don't ask for disk deletion. For now, anyway they will be deleted when
789
853
      slave restarts, but it is a better intention to not delete them.
790
854
    */
 
855
    DBUG_PRINT("info", ("table: 0x%lx", (long) table));
791
856
    close_temporary(table, 1, 0);
792
857
  }
793
858
  save_temporary_tables= 0;
794
859
  slave_open_temp_tables= 0;
795
 
  return;
 
860
  DBUG_VOID_RETURN;
796
861
}
797
862
 
798
863
/*
802
867
    Assumes to have a run lock on rli and that no slave thread are running.
803
868
*/
804
869
 
805
 
int32_t purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
 
870
int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
806
871
                     const char** errmsg)
807
872
{
808
 
  int32_t error=0;
 
873
  int error=0;
 
874
  DBUG_ENTER("purge_relay_logs");
809
875
 
810
876
  /*
811
877
    Even if rli->inited==0, we still try to empty rli->master_log_* variables.
830
896
 
831
897
  if (!rli->inited)
832
898
  {
833
 
    return(0);
 
899
    DBUG_PRINT("info", ("rli->inited == 0"));
 
900
    DBUG_RETURN(0);
834
901
  }
835
902
 
836
 
  assert(rli->slave_running == 0);
837
 
  assert(rli->mi->slave_running == 0);
 
903
  DBUG_ASSERT(rli->slave_running == 0);
 
904
  DBUG_ASSERT(rli->mi->slave_running == 0);
838
905
 
839
906
  rli->slave_skip_counter=0;
840
907
  pthread_mutex_lock(&rli->data_lock);
875
942
                              0 /* do not need data lock */, errmsg, 0);
876
943
 
877
944
err:
 
945
#ifndef DBUG_OFF
 
946
  char buf[22];
 
947
#endif
 
948
  DBUG_PRINT("info",("log_space_total: %s",llstr(rli->log_space_total,buf)));
878
949
  pthread_mutex_unlock(&rli->data_lock);
879
 
  return(error);
 
950
  DBUG_RETURN(error);
880
951
}
881
952
 
882
953
 
916
987
bool Relay_log_info::is_until_satisfied(my_off_t master_beg_pos)
917
988
{
918
989
  const char *log_name;
919
 
  uint64_t log_pos;
 
990
  ulonglong log_pos;
 
991
  DBUG_ENTER("Relay_log_info::is_until_satisfied");
920
992
 
921
 
  assert(until_condition != UNTIL_NONE);
 
993
  DBUG_ASSERT(until_condition != UNTIL_NONE);
922
994
 
923
995
  if (until_condition == UNTIL_MASTER_POS)
924
996
  {
931
1003
    log_pos= group_relay_log_pos;
932
1004
  }
933
1005
 
 
1006
#ifndef DBUG_OFF
 
1007
  {
 
1008
    char buf[32];
 
1009
    DBUG_PRINT("info", ("group_master_log_name='%s', group_master_log_pos=%s",
 
1010
                        group_master_log_name, llstr(group_master_log_pos, buf)));
 
1011
    DBUG_PRINT("info", ("group_relay_log_name='%s', group_relay_log_pos=%s",
 
1012
                        group_relay_log_name, llstr(group_relay_log_pos, buf)));
 
1013
    DBUG_PRINT("info", ("(%s) log_name='%s', log_pos=%s",
 
1014
                        until_condition == UNTIL_MASTER_POS ? "master" : "relay",
 
1015
                        log_name, llstr(log_pos, buf)));
 
1016
    DBUG_PRINT("info", ("(%s) until_log_name='%s', until_log_pos=%s",
 
1017
                        until_condition == UNTIL_MASTER_POS ? "master" : "relay",
 
1018
                        until_log_name, llstr(until_log_pos, buf)));
 
1019
  }
 
1020
#endif
 
1021
 
934
1022
  if (until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_UNKNOWN)
935
1023
  {
936
1024
    /*
946
1034
      const char *basename= log_name + dirname_length(log_name);
947
1035
 
948
1036
      const char *q= (const char*)(fn_ext(basename)+1);
949
 
      if (strncmp(basename, until_log_name, (int32_t)(q-basename)) == 0)
 
1037
      if (strncmp(basename, until_log_name, (int)(q-basename)) == 0)
950
1038
      {
951
1039
        /* Now compare extensions. */
952
1040
        char *q_end;
953
 
        uint32_t log_name_extension= strtoul(q, &q_end, 10);
 
1041
        ulong log_name_extension= strtoul(q, &q_end, 10);
954
1042
        if (log_name_extension < until_log_name_extension)
955
1043
          until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_LESS;
956
1044
        else
963
1051
        /* Probably error so we aborting */
964
1052
        sql_print_error("Slave SQL thread is stopped because UNTIL "
965
1053
                        "condition is bad.");
966
 
        return(true);
 
1054
        DBUG_RETURN(TRUE);
967
1055
      }
968
1056
    }
969
1057
    else
970
 
      return(until_log_pos == 0);
 
1058
      DBUG_RETURN(until_log_pos == 0);
971
1059
  }
972
1060
 
973
 
  return(((until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_EQUAL &&
 
1061
  DBUG_RETURN(((until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_EQUAL &&
974
1062
           log_pos >= until_log_pos) ||
975
1063
          until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_GREATER));
976
1064
}
978
1066
 
979
1067
void Relay_log_info::cached_charset_invalidate()
980
1068
{
 
1069
  DBUG_ENTER("Relay_log_info::cached_charset_invalidate");
 
1070
 
981
1071
  /* Full of zeroes means uninitialized. */
982
1072
  bzero(cached_charset, sizeof(cached_charset));
983
 
  return;
 
1073
  DBUG_VOID_RETURN;
984
1074
}
985
1075
 
986
1076
 
987
1077
bool Relay_log_info::cached_charset_compare(char *charset) const
988
1078
{
 
1079
  DBUG_ENTER("Relay_log_info::cached_charset_compare");
 
1080
 
989
1081
  if (bcmp((uchar*) cached_charset, (uchar*) charset,
990
1082
           sizeof(cached_charset)))
991
1083
  {
992
1084
    memcpy(const_cast<char*>(cached_charset), charset, sizeof(cached_charset));
993
 
    return(1);
 
1085
    DBUG_RETURN(1);
994
1086
  }
995
 
  return(0);
 
1087
  DBUG_RETURN(0);
996
1088
}
997
1089
 
998
1090
 
999
1091
void Relay_log_info::stmt_done(my_off_t event_master_log_pos,
1000
1092
                                  time_t event_creation_time)
1001
1093
{
1002
 
  extern uint32_t debug_not_change_ts_if_art_event;
 
1094
#ifndef DBUG_OFF
 
1095
  extern uint debug_not_change_ts_if_art_event;
 
1096
#endif
1003
1097
  clear_flag(IN_STMT);
1004
1098
 
1005
1099
  /*
1039
1133
      is that value may take some time to display in
1040
1134
      Seconds_Behind_Master - not critical).
1041
1135
    */
 
1136
#ifndef DBUG_OFF
1042
1137
    if (!(event_creation_time == 0 && debug_not_change_ts_if_art_event > 0))
1043
 
      last_master_timestamp= event_creation_time;
 
1138
#else
 
1139
      if (event_creation_time != 0)
 
1140
#endif
 
1141
        last_master_timestamp= event_creation_time;
1044
1142
  }
1045
1143
}
1046
1144
 
1047
1145
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1048
1146
void Relay_log_info::cleanup_context(THD *thd, bool error)
1049
1147
{
1050
 
  assert(sql_thd == thd);
 
1148
  DBUG_ENTER("Relay_log_info::cleanup_context");
 
1149
 
 
1150
  DBUG_ASSERT(sql_thd == thd);
1051
1151
  /*
1052
1152
    1) Instances of Table_map_log_event, if ::do_apply_event() was called on them,
1053
1153
    may have opened tables, which we cannot be sure have been closed (because
1075
1175
  thd->options&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
1076
1176
  thd->options&= ~OPTION_RELAXED_UNIQUE_CHECKS;
1077
1177
  last_event_start_time= 0;
1078
 
  return;
 
1178
  DBUG_VOID_RETURN;
1079
1179
}
1080
1180
 
1081
1181
void Relay_log_info::clear_tables_to_lock()
1086
1186
    if (tables_to_lock->m_tabledef_valid)
1087
1187
    {
1088
1188
      tables_to_lock->m_tabledef.table_def::~table_def();
1089
 
      tables_to_lock->m_tabledef_valid= false;
 
1189
      tables_to_lock->m_tabledef_valid= FALSE;
1090
1190
    }
1091
1191
    tables_to_lock=
1092
1192
      static_cast<RPL_TABLE_LIST*>(tables_to_lock->next_global);
1093
1193
    tables_to_lock_count--;
1094
1194
    my_free(to_free, MYF(MY_WME));
1095
1195
  }
1096
 
  assert(tables_to_lock == NULL && tables_to_lock_count == 0);
 
1196
  DBUG_ASSERT(tables_to_lock == NULL && tables_to_lock_count == 0);
1097
1197
}
1098
1198
 
1099
1199
#endif