~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to sql/rpl_reporting.cc

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "mysql_priv.h"
 
3
#include "rpl_reporting.h"
 
4
 
 
5
void
 
6
Slave_reporting_capability::report(loglevel level, int err_code,
 
7
                                   const char *msg, ...) const
 
8
{
 
9
  void (*report_function)(const char *, ...);
 
10
  char buff[MAX_SLAVE_ERRMSG];
 
11
  char *pbuff= buff;
 
12
  uint pbuffsize= sizeof(buff);
 
13
  va_list args;
 
14
  va_start(args, msg);
 
15
 
 
16
  switch (level)
 
17
  {
 
18
  case ERROR_LEVEL:
 
19
    /*
 
20
      It's an error, it must be reported in Last_error and Last_errno in SHOW
 
21
      SLAVE STATUS.
 
22
    */
 
23
    pbuff= m_last_error.message;
 
24
    pbuffsize= sizeof(m_last_error.message);
 
25
    m_last_error.number = err_code;
 
26
    report_function= sql_print_error;
 
27
    break;
 
28
  case WARNING_LEVEL:
 
29
    report_function= sql_print_warning;
 
30
    break;
 
31
  case INFORMATION_LEVEL:
 
32
    report_function= sql_print_information;
 
33
    break;
 
34
  default:
 
35
    DBUG_ASSERT(0);                            // should not come here
 
36
    return;          // don't crash production builds, just do nothing
 
37
  }
 
38
 
 
39
  my_vsnprintf(pbuff, pbuffsize, msg, args);
 
40
 
 
41
  va_end(args);
 
42
 
 
43
  /* If the msg string ends with '.', do not add a ',' it would be ugly */
 
44
  report_function("Slave %s: %s%s Error_code: %d",
 
45
                  m_thread_name, pbuff,
 
46
                  (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
 
47
                  err_code);
 
48
}