~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/diagnostics_area.h

  • Committer: Monty Taylor
  • Date: 2009-03-03 07:39:39 UTC
  • mto: This revision was merged to the branch mainline in revision 910.
  • Revision ID: mordred@inaugust.com-20090303073939-rfswfdo68klfcp1o
Updated comment version indicators to handle drizzle versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
 
20
 
20
21
#ifndef DRIZZLED_DIAGNOSTICS_AREA_H
21
22
#define DRIZZLED_DIAGNOSTICS_AREA_H
22
23
 
23
 
namespace drizzled
24
 
{
25
24
 
26
25
/**
27
26
  Stores status of the currently executed statement.
29
28
  can hold either OK, ERROR, or EOF status.
30
29
  Can not be assigned twice per statement.
31
30
*/
 
31
 
32
32
class Diagnostics_area
33
33
{
34
34
public:
51
51
  bool can_overwrite_status;
52
52
 
53
53
  void set_ok_status(Session *session, ha_rows affected_rows_arg,
54
 
                     ha_rows found_rows_arg, uint64_t last_insert_id_arg,
 
54
                     uint64_t last_insert_id_arg,
55
55
                     const char *message);
56
56
  void set_eof_status(Session *session);
57
 
  void set_error_status(drizzled::error_t sql_errno_arg, const char *message_arg);
 
57
  void set_error_status(Session *session, uint32_t sql_errno_arg, const char *message_arg);
58
58
 
59
59
  void disable_status();
60
60
 
67
67
  bool is_disabled() const { return m_status == DA_DISABLED; }
68
68
  enum_diagnostics_status status() const { return m_status; }
69
69
 
70
 
  const char *message() const;
71
 
  drizzled::error_t sql_errno() const;
72
 
  uint32_t server_status() const;
73
 
  ha_rows affected_rows() const;
74
 
  ha_rows found_rows() const;
75
 
  uint64_t last_insert_id() const;
76
 
  uint32_t total_warn_count() const;
 
70
  const char *message() const
 
71
  { assert(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
 
72
 
 
73
  uint32_t sql_errno() const
 
74
  { assert(m_status == DA_ERROR); return m_sql_errno; }
 
75
 
 
76
  uint32_t server_status() const
 
77
  {
 
78
    assert(m_status == DA_OK || m_status == DA_EOF);
 
79
    return m_server_status;
 
80
  }
 
81
 
 
82
  ha_rows affected_rows() const
 
83
  { assert(m_status == DA_OK); return m_affected_rows; }
 
84
 
 
85
  uint64_t last_insert_id() const
 
86
  { assert(m_status == DA_OK); return m_last_insert_id; }
 
87
 
 
88
  uint32_t total_warn_count() const
 
89
  {
 
90
    assert(m_status == DA_OK || m_status == DA_EOF);
 
91
    return m_total_warn_count;
 
92
  }
77
93
 
78
94
  Diagnostics_area() { reset_diagnostics_area(); }
79
95
 
84
100
    SQL error number. One of ER_ codes from share/errmsg.txt.
85
101
    Set by set_error_status.
86
102
  */
87
 
  drizzled::error_t m_sql_errno;
 
103
  uint32_t m_sql_errno;
88
104
 
89
105
  /**
90
106
    Copied from session->server_status when the diagnostics area is assigned.
95
111
    Assigned by OK, EOF or ERROR.
96
112
  */
97
113
  uint32_t m_server_status;
98
 
 
99
114
  /**
100
115
    The number of rows affected by the last statement. This is
101
116
    semantically close to session->row_count_func, but has a different
107
122
    We could possibly merge the two, but life cycle of session->row_count_func
108
123
    can not be changed.
109
124
  */
110
 
  ha_rows m_affected_rows;
111
 
  /**
112
 
    This is like m_affected_rows, but contains the number of rows found, not
113
 
    only affected.
114
 
  */
115
 
  ha_rows m_found_rows;
 
125
  ha_rows    m_affected_rows;
116
126
  /**
117
127
    Similarly to the previous member, this is a replacement of
118
128
    session->first_successful_insert_id_in_prev_stmt, which is used
119
129
    to implement LAST_INSERT_ID().
120
130
  */
121
 
  uint64_t m_last_insert_id;
 
131
  uint64_t   m_last_insert_id;
122
132
  /** The total number of warnings. */
123
 
  uint32_t m_total_warn_count;
 
133
  uint       m_total_warn_count;
124
134
  enum_diagnostics_status m_status;
125
135
  /**
126
136
    @todo: the following Session members belong here:
128
138
  */
129
139
};
130
140
 
131
 
} /* namespace drizzled */
132
 
 
133
141
#endif /* DRIZZLED_DIAGNOSTICS_AREA_H */