1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems
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.
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.
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
20
#include "drizzled/global.h"
21
#include "drizzled/session.h"
22
#include "drizzled/diagnostics_area.h"
25
Clear this diagnostics area.
27
Normally called at the end of a statement.
29
void Diagnostics_area::reset_diagnostics_area()
31
can_overwrite_status= false;
32
/** Don't take chances in production */
38
m_total_warn_count= 0;
40
/** Tiny reset in debug mode to see garbage right away */
45
Set OK status -- ends commands that do not return a
46
result set, e.g. INSERT/UPDATE/DELETE.
48
void Diagnostics_area::set_ok_status(Session *session, ha_rows affected_rows_arg,
49
uint64_t last_insert_id_arg,
50
const char *message_arg)
54
In production, refuse to overwrite an error or a custom response
57
if (is_error() || is_disabled())
59
/** Only allowed to report success if has not yet reported an error */
61
m_server_status= session->server_status;
62
m_total_warn_count= session->total_warn_count;
63
m_affected_rows= affected_rows_arg;
64
m_last_insert_id= last_insert_id_arg;
66
strncpy(m_message, message_arg, sizeof(m_message) - 1);
75
void Diagnostics_area::set_eof_status(Session *session)
77
/** Only allowed to report eof if has not yet reported an error */
81
In production, refuse to overwrite an error or a custom response
84
if (is_error() || is_disabled())
87
m_server_status= session->server_status;
89
If inside a stored procedure, do not return the total
90
number of warnings, since they are not available to the client
93
m_total_warn_count= session->total_warn_count;
101
void Diagnostics_area::set_error_status(Session *,
102
uint32_t sql_errno_arg,
103
const char *message_arg)
106
Only allowed to report error if has not yet reported a success
107
The only exception is when we flush the message to the client,
108
an error can happen during the flush.
110
assert(! is_set() || can_overwrite_status);
112
In production, refuse to overwrite a custom response with an
118
m_sql_errno= sql_errno_arg;
119
strncpy(m_message, message_arg, sizeof(m_message) - 1);
125
Mark the diagnostics area as 'DISABLED'.
127
This is used in rare cases when the COM_ command at hand sends a response
128
in a custom format. One example is the query cache, another is
131
void Diagnostics_area::disable_status()
134
m_status= DA_DISABLED;