851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
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 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
20 |
#pragma once
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
21 |
|
2239.1.3
by Olaf van der Spek
Refactor includes |
22 |
#include <drizzled/base.h> |
23 |
#include <drizzled/error_t.h> |
|
24 |
||
25 |
namespace drizzled { |
|
26 |
||
27 |
class Session; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
28 |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
29 |
/**
|
30 |
Stores status of the currently executed statement.
|
|
31 |
Cleared at the beginning of the statement, and then
|
|
32 |
can hold either OK, ERROR, or EOF status.
|
|
33 |
Can not be assigned twice per statement.
|
|
34 |
*/
|
|
35 |
class Diagnostics_area |
|
36 |
{
|
|
37 |
public: |
|
38 |
enum enum_diagnostics_status |
|
39 |
{
|
|
40 |
/** The area is cleared at start of a statement. */
|
|
41 |
DA_EMPTY= 0, |
|
42 |
/** Set whenever one calls my_ok(). */
|
|
43 |
DA_OK, |
|
44 |
/** Set whenever one calls my_eof(). */
|
|
45 |
DA_EOF, |
|
46 |
/** Set whenever one calls my_error() or my_message(). */
|
|
47 |
DA_ERROR, |
|
48 |
/** Set in case of a custom response, such as one from COM_STMT_PREPARE. */
|
|
49 |
DA_DISABLED
|
|
50 |
};
|
|
51 |
/** True if status information is sent to the client. */
|
|
52 |
bool is_sent; |
|
53 |
/** Set to make set_error_status after set_{ok,eof}_status possible. */
|
|
54 |
bool can_overwrite_status; |
|
55 |
||
56 |
void set_ok_status(Session *session, ha_rows affected_rows_arg, |
|
971.3.59
by Eric Day
Removed client_capabilities from session and pushed functionality into protocol plugin. |
57 |
ha_rows found_rows_arg, uint64_t last_insert_id_arg, |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
58 |
const char *message); |
59 |
void set_eof_status(Session *session); |
|
2126.3.4
by Brian Aker
Additional error cleanup (passing error correctly to the client code). |
60 |
void set_error_status(drizzled::error_t sql_errno_arg, const char *message_arg); |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
61 |
|
62 |
void disable_status(); |
|
63 |
||
64 |
void reset_diagnostics_area(); |
|
65 |
||
66 |
bool is_set() const { return m_status != DA_EMPTY; } |
|
67 |
bool is_error() const { return m_status == DA_ERROR; } |
|
68 |
bool is_eof() const { return m_status == DA_EOF; } |
|
69 |
bool is_ok() const { return m_status == DA_OK; } |
|
70 |
bool is_disabled() const { return m_status == DA_DISABLED; } |
|
71 |
enum_diagnostics_status status() const { return m_status; } |
|
72 |
||
1022.2.29
by Monty Taylor
Fixed some no-inline warnings. |
73 |
const char *message() const; |
2126.3.4
by Brian Aker
Additional error cleanup (passing error correctly to the client code). |
74 |
drizzled::error_t sql_errno() const; |
1022.2.29
by Monty Taylor
Fixed some no-inline warnings. |
75 |
uint32_t server_status() const; |
76 |
ha_rows affected_rows() const; |
|
971.3.59
by Eric Day
Removed client_capabilities from session and pushed functionality into protocol plugin. |
77 |
ha_rows found_rows() const; |
1022.2.29
by Monty Taylor
Fixed some no-inline warnings. |
78 |
uint64_t last_insert_id() const; |
79 |
uint32_t total_warn_count() const; |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
80 |
|
81 |
Diagnostics_area() { reset_diagnostics_area(); } |
|
82 |
||
83 |
private: |
|
84 |
/** Message buffer. Can be used by OK or ERROR status. */
|
|
85 |
char m_message[DRIZZLE_ERRMSG_SIZE]; |
|
86 |
/**
|
|
87 |
SQL error number. One of ER_ codes from share/errmsg.txt.
|
|
88 |
Set by set_error_status.
|
|
89 |
*/
|
|
2126.3.4
by Brian Aker
Additional error cleanup (passing error correctly to the client code). |
90 |
drizzled::error_t m_sql_errno; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
91 |
|
92 |
/**
|
|
93 |
Copied from session->server_status when the diagnostics area is assigned.
|
|
94 |
We need this member as some places in the code use the following pattern:
|
|
95 |
session->server_status|= ...
|
|
96 |
my_eof(session);
|
|
97 |
session->server_status&= ~...
|
|
98 |
Assigned by OK, EOF or ERROR.
|
|
99 |
*/
|
|
100 |
uint32_t m_server_status; |
|
2126.3.4
by Brian Aker
Additional error cleanup (passing error correctly to the client code). |
101 |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
102 |
/**
|
103 |
The number of rows affected by the last statement. This is
|
|
104 |
semantically close to session->row_count_func, but has a different
|
|
105 |
life cycle. session->row_count_func stores the value returned by
|
|
106 |
function ROW_COUNT() and is cleared only by statements that
|
|
107 |
update its value, such as INSERT, UPDATE, DELETE and few others.
|
|
108 |
This member is cleared at the beginning of the next statement.
|
|
109 |
||
110 |
We could possibly merge the two, but life cycle of session->row_count_func
|
|
111 |
can not be changed.
|
|
112 |
*/
|
|
1055.2.13
by Jay Pipes
Documentation and style fixes in Session class. Doxygen should finally pick up the Statement and Session classes now. Removes the silly Query_arena class, as it's not needed anymore. |
113 |
ha_rows m_affected_rows; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
114 |
/**
|
971.3.59
by Eric Day
Removed client_capabilities from session and pushed functionality into protocol plugin. |
115 |
This is like m_affected_rows, but contains the number of rows found, not
|
116 |
only affected.
|
|
117 |
*/
|
|
118 |
ha_rows m_found_rows; |
|
119 |
/**
|
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
120 |
Similarly to the previous member, this is a replacement of
|
121 |
session->first_successful_insert_id_in_prev_stmt, which is used
|
|
122 |
to implement LAST_INSERT_ID().
|
|
123 |
*/
|
|
1055.2.13
by Jay Pipes
Documentation and style fixes in Session class. Doxygen should finally pick up the Statement and Session classes now. Removes the silly Query_arena class, as it's not needed anymore. |
124 |
uint64_t m_last_insert_id; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
125 |
/** The total number of warnings. */
|
1055.2.13
by Jay Pipes
Documentation and style fixes in Session class. Doxygen should finally pick up the Statement and Session classes now. Removes the silly Query_arena class, as it's not needed anymore. |
126 |
uint32_t m_total_warn_count; |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
127 |
enum_diagnostics_status m_status; |
128 |
/**
|
|
129 |
@todo: the following Session members belong here:
|
|
130 |
- warn_list, warn_count,
|
|
131 |
*/
|
|
132 |
};
|
|
133 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
134 |
} /* namespace drizzled */ |
135 |