~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/rpl_reporting.h

  • Committer: Stewart Smith
  • Date: 2009-06-16 03:02:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1065.
  • Revision ID: stewart@flamingspork.com-20090616030259-tn2thqrajk6cappd
ER_NISAMCHK is unused, mark it as so. Thanks to Paul DuBois for researching this for MySQL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef RPL_REPORTING_H
21
 
#define RPL_REPORTING_H
22
 
 
23
 
/**
24
 
   Maximum size of an error message from a slave thread.
25
 
 */
26
 
#define MAX_SLAVE_ERRMSG      1024
27
 
 
28
 
/**
29
 
   Mix-in to handle the message logging and reporting for relay log
30
 
   info and master log info structures.
31
 
 
32
 
   By inheriting from this class, the class is imbued with
33
 
   capabilities to do slave reporting.
34
 
 */
35
 
class Slave_reporting_capability
36
 
{
37
 
public:
38
 
  /**
39
 
     Constructor.
40
 
 
41
 
     @param thread_name Printable name of the slave thread that is reporting.
42
 
   */
43
 
  Slave_reporting_capability(char const *thread_name)
44
 
    : m_thread_name(thread_name)
45
 
  {
46
 
  }
47
 
 
48
 
  /**
49
 
     Writes a message and, if it's an error message, to Last_Error
50
 
     (which will be displayed by SHOW SLAVE STATUS).
51
 
 
52
 
     @param level       The severity level
53
 
     @param err_code    The error code
54
 
     @param msg         The message (usually related to the error
55
 
                        code, but can contain more information), in
56
 
                        printf() format.
57
 
  */
58
 
  void report(loglevel level, int err_code, const char *msg, ...) const
59
 
    __attribute__((format(printf, 4, 5)));
60
 
 
61
 
  /**
62
 
     Clear errors. They will not show up under <code>SHOW SLAVE
63
 
     STATUS</code>.
64
 
   */
65
 
  void clear_error() {
66
 
    m_last_error.clear();
67
 
  }
68
 
 
69
 
  /**
70
 
     Error information structure.
71
 
   */
72
 
  class Error {
73
 
    friend class Slave_reporting_capability;
74
 
  public:
75
 
    Error()
76
 
    {
77
 
      clear();
78
 
    }
79
 
 
80
 
    void clear()
81
 
    {
82
 
      number= 0;
83
 
      message[0]= '\0';
84
 
    }
85
 
 
86
 
    /** Error code */
87
 
    uint32_t number;
88
 
    /** Error message */
89
 
    char message[MAX_SLAVE_ERRMSG];
90
 
  };
91
 
 
92
 
  Error const& last_error() const { return m_last_error; }
93
 
 
94
 
private:
95
 
  /**
96
 
     Last error produced by the I/O or SQL thread respectively.
97
 
   */
98
 
  mutable Error m_last_error;
99
 
 
100
 
  char const *const m_thread_name;
101
 
};
102
 
 
103
 
#endif // RPL_REPORTING_H
104