520.6.3
by Monty Taylor
Moved scheduler.h out of common_includes. |
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 |
*/
|
|
1
by brian
clean slate |
19 |
|
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. |
20 |
/**
|
21 |
* @file Implementation of the Session class and API
|
|
22 |
*/
|
|
23 |
||
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
24 |
#include "config.h" |
1861.6.1
by David Shrewsbury
Add method to undo adding records to a Statement message in case of multi-row statement failure. |
25 |
#include "drizzled/session.h" |
1241.9.17
by Monty Taylor
Removed more bits from server_includes. |
26 |
#include "drizzled/session_list.h" |
1
by brian
clean slate |
27 |
#include <sys/stat.h> |
1861.6.1
by David Shrewsbury
Add method to undo adding records to a Statement message in case of multi-row statement failure. |
28 |
#include "drizzled/error.h" |
29 |
#include "drizzled/gettext.h" |
|
30 |
#include "drizzled/query_id.h" |
|
31 |
#include "drizzled/data_home.h" |
|
32 |
#include "drizzled/sql_base.h" |
|
33 |
#include "drizzled/lock.h" |
|
34 |
#include "drizzled/item/cache.h" |
|
35 |
#include "drizzled/item/float.h" |
|
36 |
#include "drizzled/item/return_int.h" |
|
37 |
#include "drizzled/item/empty_string.h" |
|
38 |
#include "drizzled/show.h" |
|
39 |
#include "drizzled/plugin/client.h" |
|
1130.1.3
by Monty Taylor
Merged up with trunk. |
40 |
#include "drizzled/plugin/scheduler.h" |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
41 |
#include "drizzled/plugin/authentication.h" |
1316.1.1
by Joe Daly
add plugin handle to logging to indicate when the session destructor is called |
42 |
#include "drizzled/plugin/logging.h" |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
43 |
#include "drizzled/plugin/transactional_storage_engine.h" |
1126.10.18
by Padraig O'Sullivan
Various small build fixes for when dtrace is enabled. |
44 |
#include "drizzled/probes.h" |
1130.3.9
by Monty Taylor
Wrapped table_proto_write.cc code in namespace drizzled. |
45 |
#include "drizzled/table_proto.h" |
1235.4.23
by Stewart Smith
fix includes for drizzled/db.h. Now only in .cc files, no header files. should make modifying db.h much less painful. |
46 |
#include "drizzled/db.h" |
1241.9.31
by Monty Taylor
Moved global pthread variables into their own header. |
47 |
#include "drizzled/pthread_globals.h" |
1273.1.2
by Jay Pipes
This patch does not change any algorithms or code paths, |
48 |
#include "drizzled/transaction_services.h" |
1300.5.2
by Monty Taylor
Changed build to build the almost all of drizzle into libdrizzled and then |
49 |
#include "drizzled/drizzled.h" |
1241.9.31
by Monty Taylor
Moved global pthread variables into their own header. |
50 |
|
1843.8.4
by Brian Aker
Committing refactor of table out (this is part of the concurrency work). |
51 |
#include "drizzled/table/instance.h" |
1532.1.1
by Brian Aker
Merge of change to flip table instance to be share instance |
52 |
|
1241.9.62
by Monty Taylor
Removed plugin/myisam/myisam.h from session.h |
53 |
#include "plugin/myisam/myisam.h" |
1241.9.64
by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal. |
54 |
#include "drizzled/internal/iocache.h" |
1689.2.10
by Brian Aker
Move thread_var out to its own include file. |
55 |
#include "drizzled/internal/thread_var.h" |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
56 |
#include "drizzled/plugin/event_observer.h" |
1
by brian
clean slate |
57 |
|
1843.8.4
by Brian Aker
Committing refactor of table out (this is part of the concurrency work). |
58 |
#include "drizzled/util/functors.h" |
59 |
||
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
60 |
#include "drizzled/display.h" |
61 |
||
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
62 |
#include <fcntl.h> |
1067.4.1
by Nathan Williams
First few changes at converting cmin to std::min. |
63 |
#include <algorithm> |
1241.9.24
by Monty Taylor
Removed m_string.h from server_includes.h. |
64 |
#include <climits> |
1861.6.1
by David Shrewsbury
Add method to undo adding records to a Statement message in case of multi-row statement failure. |
65 |
#include <boost/filesystem.hpp> |
1067.4.1
by Nathan Williams
First few changes at converting cmin to std::min. |
66 |
|
1932.3.13
by Brian Aker
Cleanup session ownership rules such that we know exactly when session has |
67 |
#include "drizzled/util/backtrace.h" |
68 |
||
1067.4.1
by Nathan Williams
First few changes at converting cmin to std::min. |
69 |
using namespace std; |
1786.3.2
by Monty Taylor
Cleaned up the initial pass at this. It's not perfect, but it does work. |
70 |
|
71 |
namespace fs=boost::filesystem; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
72 |
namespace drizzled |
73 |
{
|
|
1067.4.1
by Nathan Williams
First few changes at converting cmin to std::min. |
74 |
|
1
by brian
clean slate |
75 |
/*
|
76 |
The following is used to initialise Table_ident with a internal
|
|
77 |
table name
|
|
78 |
*/
|
|
79 |
char internal_table_name[2]= "*"; |
|
80 |
char empty_c_string[1]= {0}; /* used for not defined db */ |
|
81 |
||
520.1.21
by Brian Aker
THD -> Session rename |
82 |
const char * const Session::DEFAULT_WHERE= "field list"; |
1
by brian
clean slate |
83 |
|
84 |
bool Key_part_spec::operator==(const Key_part_spec& other) const |
|
85 |
{
|
|
86 |
return length == other.length && |
|
87 |
field_name.length == other.field_name.length && |
|
88 |
!strcmp(field_name.str, other.field_name.str); |
|
89 |
}
|
|
90 |
||
1539
by Brian Aker
Simplify out Open_tables_state() backup/restore (no longer needed). |
91 |
Open_tables_state::Open_tables_state(uint64_t version_arg) : |
92 |
version(version_arg) |
|
1
by brian
clean slate |
93 |
{
|
1539
by Brian Aker
Simplify out Open_tables_state() backup/restore (no longer needed). |
94 |
open_tables= temporary_tables= derived_tables= NULL; |
95 |
extra_lock= lock= NULL; |
|
1
by brian
clean slate |
96 |
}
|
97 |
||
98 |
/*
|
|
99 |
The following functions form part of the C plugin API
|
|
100 |
*/
|
|
1471.5.2
by mordred
Removed some extern "C" bits that were screwing with the callstack. |
101 |
int mysql_tmpfile(const char *prefix) |
1
by brian
clean slate |
102 |
{
|
103 |
char filename[FN_REFLEN]; |
|
1556.1.1
by Brian Aker
Updates for moving temporary directory. |
104 |
int fd = internal::create_temp_file(filename, drizzle_tmpdir.c_str(), prefix, MYF(MY_WME)); |
1
by brian
clean slate |
105 |
if (fd >= 0) { |
106 |
unlink(filename); |
|
107 |
}
|
|
108 |
||
109 |
return fd; |
|
110 |
}
|
|
111 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
112 |
int session_tablespace_op(const Session *session) |
1
by brian
clean slate |
113 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
114 |
return test(session->tablespace_op); |
1
by brian
clean slate |
115 |
}
|
116 |
||
322.2.5
by Mats Kindahl
Replaced use of thd_proc_info() macro with calls to |
117 |
/**
|
520.1.21
by Brian Aker
THD -> Session rename |
118 |
Set the process info field of the Session structure.
|
322.2.5
by Mats Kindahl
Replaced use of thd_proc_info() macro with calls to |
119 |
|
120 |
This function is used by plug-ins. Internally, the
|
|
520.1.21
by Brian Aker
THD -> Session rename |
121 |
Session::set_proc_info() function should be used.
|
322.2.5
by Mats Kindahl
Replaced use of thd_proc_info() macro with calls to |
122 |
|
520.1.21
by Brian Aker
THD -> Session rename |
123 |
@see Session::set_proc_info
|
322.2.5
by Mats Kindahl
Replaced use of thd_proc_info() macro with calls to |
124 |
*/
|
1471.5.2
by mordred
Removed some extern "C" bits that were screwing with the callstack. |
125 |
void set_session_proc_info(Session *session, const char *info) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
126 |
{
|
127 |
session->set_proc_info(info); |
|
128 |
}
|
|
129 |
||
130 |
const char *get_session_proc_info(Session *session) |
|
131 |
{
|
|
132 |
return session->get_proc_info(); |
|
133 |
}
|
|
134 |
||
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
135 |
void **Session::getEngineData(const plugin::MonitoredInTransaction *monitored) |
1240.9.6
by Monty Taylor
Removed some casts- also removed a few c-interface functions and made them actual methods on session. Also made the ha_data private. (fancy that) |
136 |
{
|
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
137 |
return static_cast<void **>(&ha_data[monitored->getId()].ha_ptr); |
1240.9.6
by Monty Taylor
Removed some casts- also removed a few c-interface functions and made them actual methods on session. Also made the ha_data private. (fancy that) |
138 |
}
|
139 |
||
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
140 |
ResourceContext *Session::getResourceContext(const plugin::MonitoredInTransaction *monitored, |
1273.1.10
by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext |
141 |
size_t index) |
1240.9.6
by Monty Taylor
Removed some casts- also removed a few c-interface functions and made them actual methods on session. Also made the ha_data private. (fancy that) |
142 |
{
|
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
143 |
return &ha_data[monitored->getId()].resource_context[index]; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
144 |
}
|
145 |
||
146 |
int64_t session_test_options(const Session *session, int64_t test_options) |
|
147 |
{
|
|
148 |
return session->options & test_options; |
|
149 |
}
|
|
150 |
||
151 |
int session_sql_command(const Session *session) |
|
152 |
{
|
|
153 |
return (int) session->lex->sql_command; |
|
154 |
}
|
|
155 |
||
1578.7.1
by Stewart Smith
change session_tx_isolation() to return enum_tx_isolation instead of int. This means that in engines we can properly use a switch statement on the enum values and get warnings if we miss one. |
156 |
enum_tx_isolation session_tx_isolation(const Session *session) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
157 |
{
|
1578.7.1
by Stewart Smith
change session_tx_isolation() to return enum_tx_isolation instead of int. This means that in engines we can properly use a switch statement on the enum values and get warnings if we miss one. |
158 |
return (enum_tx_isolation)session->variables.tx_isolation; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
159 |
}
|
160 |
||
1539
by Brian Aker
Simplify out Open_tables_state() backup/restore (no longer needed). |
161 |
Session::Session(plugin::Client *client_arg) : |
1055.2.16
by Jay Pipes
Removes dead Session::catalog member variable |
162 |
Open_tables_state(refresh_version), |
1100.3.29
by Padraig O'Sullivan
Removed the Statement class. Copied any members it had that were needed by |
163 |
mem_root(&main_mem_root), |
1856.2.20
by Joseph Daly
fix valgrind message |
164 |
xa_id(0), |
1100.3.29
by Padraig O'Sullivan
Removed the Statement class. Copied any members it had that were needed by |
165 |
lex(&main_lex), |
1932.3.2
by Brian Aker
1) Make sure the query string always has an std::string in it. |
166 |
query(new std::string), |
1864.3.1
by Brian Aker
Add a catalog() command. |
167 |
catalog("LOCAL"), |
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
168 |
client(client_arg), |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
169 |
scheduler(NULL), |
170 |
scheduler_arg(NULL), |
|
1055.2.16
by Jay Pipes
Removes dead Session::catalog member variable |
171 |
lock_id(&main_lock_id), |
172 |
user_time(0), |
|
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
173 |
ha_data(plugin::num_trx_monitored_objects), |
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
174 |
concurrent_execute_allowed(true), |
1055.2.16
by Jay Pipes
Removes dead Session::catalog member variable |
175 |
arg_of_last_insert_id_function(false), |
176 |
first_successful_insert_id_in_prev_stmt(0), |
|
177 |
first_successful_insert_id_in_cur_stmt(0), |
|
1055.2.17
by Jay Pipes
More style cleanups in Session |
178 |
limit_found_rows(0), |
1910.2.2
by Brian Aker
First pass through the global lock refactor merge. |
179 |
_global_read_lock(NONE), |
1910.2.8
by Brian Aker
Enapsulate Kill. |
180 |
_killed(NOT_KILLED), |
1055.2.17
by Jay Pipes
More style cleanups in Session |
181 |
some_tables_deleted(false), |
182 |
no_errors(false), |
|
183 |
password(false), |
|
184 |
is_fatal_error(false), |
|
185 |
transaction_rollback_request(false), |
|
1055.2.16
by Jay Pipes
Removes dead Session::catalog member variable |
186 |
is_fatal_sub_stmt_error(0), |
187 |
derived_tables_processing(false), |
|
1055.2.17
by Jay Pipes
More style cleanups in Session |
188 |
tablespace_op(false), |
1055.2.16
by Jay Pipes
Removes dead Session::catalog member variable |
189 |
m_lip(NULL), |
1143.2.11
by Jay Pipes
Fixes a bug appearing on hades b/c forgot to initalize statement_message and transaction_message members of Session to NULL |
190 |
cached_table(0), |
191 |
transaction_message(NULL), |
|
1502.5.2
by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin. |
192 |
statement_message(NULL), |
1764.3.6
by Brian Aker
This includes a query_usage table for looking at performance of previous |
193 |
session_event_observers(NULL), |
194 |
use_usage(false) |
|
1
by brian
clean slate |
195 |
{
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
196 |
client->setSession(this); |
961.1.3
by Brian Aker
Remove additional lock for proceslist. |
197 |
|
1
by brian
clean slate |
198 |
/*
|
199 |
Pass nominal parameters to init_alloc_root only to ensure that
|
|
200 |
the destructor works OK in case of an error. The main_mem_root
|
|
201 |
will be re-initialized in init_for_queries().
|
|
202 |
*/
|
|
1253.1.6
by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace. |
203 |
memory::init_sql_alloc(&main_mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0); |
1055.2.17
by Jay Pipes
More style cleanups in Session |
204 |
thread_stack= NULL; |
1633.4.8
by Brian Aker
Update for count_cuted_fields. |
205 |
count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; |
1055.2.17
by Jay Pipes
More style cleanups in Session |
206 |
col_access= 0; |
207 |
tmp_table= 0; |
|
208 |
used_tables= 0; |
|
1
by brian
clean slate |
209 |
cuted_fields= sent_row_count= row_count= 0L; |
210 |
row_count_func= -1; |
|
211 |
statement_id_counter= 0UL; |
|
520.1.21
by Brian Aker
THD -> Session rename |
212 |
// Must be reset to handle error with Session's created for init of mysqld
|
1
by brian
clean slate |
213 |
lex->current_select= 0; |
214 |
start_time=(time_t) 0; |
|
215 |
start_utime= 0L; |
|
216 |
utime_after_lock= 0L; |
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
217 |
memset(&variables, 0, sizeof(variables)); |
1
by brian
clean slate |
218 |
thread_id= 0; |
219 |
file_id = 0; |
|
220 |
query_id= 0; |
|
1273.1.1
by Jay Pipes
* Changes Session::warn_id to Session::warn_query_id |
221 |
warn_query_id= 0; |
1055.2.17
by Jay Pipes
More style cleanups in Session |
222 |
mysys_var= 0; |
1561.3.20
by Joe Daly
add a index in session.h this will allow repeated lookups without having to iterate through the scoreboard looking for our slot |
223 |
scoreboard_index= -1; |
520.1.21
by Brian Aker
THD -> Session rename |
224 |
dbug_sentry=Session_SENTRY_MAGIC; |
1643.6.13
by Djellel E. Difallah
adding tests |
225 |
cleanup_done= abort_on_warning= no_warnings_for_error= false; |
226 |
||
1643.6.1
by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin |
227 |
/* query_cache init */
|
228 |
query_cache_key= ""; |
|
229 |
resultset= NULL; |
|
1
by brian
clean slate |
230 |
|
231 |
/* Variables with default values */
|
|
232 |
proc_info="login"; |
|
520.1.21
by Brian Aker
THD -> Session rename |
233 |
where= Session::DEFAULT_WHERE; |
1055.2.17
by Jay Pipes
More style cleanups in Session |
234 |
command= COM_CONNECT; |
1
by brian
clean slate |
235 |
|
1039.1.13
by Brian Aker
Removed dead bit in Session. |
236 |
plugin_sessionvar_init(this); |
237 |
/*
|
|
238 |
variables= global_system_variables above has reset
|
|
239 |
variables.pseudo_thread_id to 0. We need to correct it here to
|
|
240 |
avoid temporary tables replication failure.
|
|
241 |
*/
|
|
242 |
variables.pseudo_thread_id= thread_id; |
|
243 |
server_status= SERVER_STATUS_AUTOCOMMIT; |
|
244 |
options= session_startup_options; |
|
245 |
||
246 |
if (variables.max_join_size == HA_POS_ERROR) |
|
247 |
options |= OPTION_BIG_SELECTS; |
|
248 |
else
|
|
249 |
options &= ~OPTION_BIG_SELECTS; |
|
250 |
||
251 |
open_options=ha_open_options; |
|
252 |
update_lock_default= TL_WRITE; |
|
253 |
session_tx_isolation= (enum_tx_isolation) variables.tx_isolation; |
|
254 |
warn_list.empty(); |
|
255 |
memset(warn_count, 0, sizeof(warn_count)); |
|
256 |
total_warn_count= 0; |
|
257 |
memset(&status_var, 0, sizeof(status_var)); |
|
258 |
||
1
by brian
clean slate |
259 |
/* Initialize sub structures */
|
1253.1.6
by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace. |
260 |
memory::init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE); |
1
by brian
clean slate |
261 |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
262 |
substitute_null_with_insert_id = false; |
1689.2.12
by Brian Aker
THR_LOCK_INFO::init() <-- encapsulation |
263 |
lock_info.init(); /* safety: will be reset after start */ |
1
by brian
clean slate |
264 |
thr_lock_owner_init(&main_lock_id, &lock_info); |
265 |
||
266 |
m_internal_handler= NULL; |
|
1502.5.2
by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin. |
267 |
|
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
268 |
plugin::EventObserver::registerSessionEvents(*this); |
1
by brian
clean slate |
269 |
}
|
270 |
||
1100.3.29
by Padraig O'Sullivan
Removed the Statement class. Copied any members it had that were needed by |
271 |
void Session::free_items() |
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. |
272 |
{
|
273 |
Item *next; |
|
1253.1.6
by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace. |
274 |
/* This works because items are allocated with memory::sql_alloc() */
|
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. |
275 |
for (; free_list; free_list= next) |
276 |
{
|
|
277 |
next= free_list->next; |
|
278 |
free_list->delete_self(); |
|
279 |
}
|
|
280 |
}
|
|
1
by brian
clean slate |
281 |
|
520.1.21
by Brian Aker
THD -> Session rename |
282 |
void Session::push_internal_handler(Internal_error_handler *handler) |
1
by brian
clean slate |
283 |
{
|
284 |
/*
|
|
285 |
TODO: The current implementation is limited to 1 handler at a time only.
|
|
520.1.21
by Brian Aker
THD -> Session rename |
286 |
Session and sp_rcontext need to be modified to use a common handler stack.
|
1
by brian
clean slate |
287 |
*/
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
288 |
assert(m_internal_handler == NULL); |
1
by brian
clean slate |
289 |
m_internal_handler= handler; |
290 |
}
|
|
291 |
||
520.1.21
by Brian Aker
THD -> Session rename |
292 |
bool Session::handle_error(uint32_t sql_errno, const char *message, |
261.4.1
by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR. |
293 |
DRIZZLE_ERROR::enum_warning_level level) |
1
by brian
clean slate |
294 |
{
|
295 |
if (m_internal_handler) |
|
296 |
{
|
|
297 |
return m_internal_handler->handle_error(sql_errno, message, level, this); |
|
298 |
}
|
|
299 |
||
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
300 |
return false; // 'false', as per coding style |
1
by brian
clean slate |
301 |
}
|
302 |
||
1689.2.26
by Brian Aker
More encapsulation of the thread var. |
303 |
void Session::setAbort(bool arg) |
304 |
{
|
|
305 |
mysys_var->abort= arg; |
|
306 |
}
|
|
307 |
||
308 |
void Session::lockOnSys() |
|
309 |
{
|
|
310 |
if (not mysys_var) |
|
311 |
return; |
|
312 |
||
313 |
setAbort(true); |
|
1812.3.7
by Brian Aker
Typdef our lock type. |
314 |
boost_unique_lock_t scopedLock(mysys_var->mutex); |
1689.2.26
by Brian Aker
More encapsulation of the thread var. |
315 |
if (mysys_var->current_cond) |
316 |
{
|
|
1786.2.1
by Brian Aker
Current boost work (more conversion). |
317 |
mysys_var->current_mutex->lock(); |
1798.3.1
by Brian Aker
Remove native_handle usage. |
318 |
mysys_var->current_cond->notify_all(); |
1786.2.1
by Brian Aker
Current boost work (more conversion). |
319 |
mysys_var->current_mutex->unlock(); |
1689.2.26
by Brian Aker
More encapsulation of the thread var. |
320 |
}
|
321 |
}
|
|
322 |
||
520.1.21
by Brian Aker
THD -> Session rename |
323 |
void Session::pop_internal_handler() |
1
by brian
clean slate |
324 |
{
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
325 |
assert(m_internal_handler != NULL); |
1
by brian
clean slate |
326 |
m_internal_handler= NULL; |
327 |
}
|
|
328 |
||
1490
by Brian Aker
Updates to remove a fe bits of dead code around C support for plugins |
329 |
void Session::get_xid(DRIZZLE_XID *xid) |
330 |
{
|
|
331 |
*xid = *(DRIZZLE_XID *) &transaction.xid_state.xid; |
|
332 |
}
|
|
333 |
||
1
by brian
clean slate |
334 |
/* Do operations that may take a long time */
|
335 |
||
520.1.21
by Brian Aker
THD -> Session rename |
336 |
void Session::cleanup(void) |
1
by brian
clean slate |
337 |
{
|
947
by Brian Aker
Merge fix |
338 |
assert(cleanup_done == false); |
1
by brian
clean slate |
339 |
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
340 |
setKilled(KILL_CONNECTION); |
1
by brian
clean slate |
341 |
#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
|
342 |
if (transaction.xid_state.xa_state == XA_PREPARED) |
|
343 |
{
|
|
344 |
#error xid_state in the cache should be replaced by the allocated value
|
|
345 |
}
|
|
346 |
#endif
|
|
347 |
{
|
|
1273.1.2
by Jay Pipes
This patch does not change any algorithms or code paths, |
348 |
TransactionServices &transaction_services= TransactionServices::singleton(); |
1405.3.5
by Jay Pipes
TransactionServices method names now meet code style guidelines. |
349 |
transaction_services.rollbackTransaction(this, true); |
1
by brian
clean slate |
350 |
xid_cache_delete(&transaction.xid_state); |
351 |
}
|
|
1689.3.4
by Brian Aker
Remove the hash in session, for a boost based one. |
352 |
|
353 |
for (UserVars::iterator iter= user_vars.begin(); |
|
354 |
iter != user_vars.end(); |
|
355 |
iter++) |
|
356 |
{
|
|
357 |
user_var_entry *entry= (*iter).second; |
|
358 |
delete entry; |
|
359 |
}
|
|
360 |
user_vars.clear(); |
|
361 |
||
362 |
||
793
by Brian Aker
Pass through on refactoring functions to clases. |
363 |
close_temporary_tables(); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
364 |
|
1
by brian
clean slate |
365 |
if (global_read_lock) |
1910.2.2
by Brian Aker
First pass through the global lock refactor merge. |
366 |
{
|
367 |
unlockGlobalReadLock(); |
|
368 |
}
|
|
1
by brian
clean slate |
369 |
|
947
by Brian Aker
Merge fix |
370 |
cleanup_done= true; |
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
371 |
}
|
1
by brian
clean slate |
372 |
|
520.1.21
by Brian Aker
THD -> Session rename |
373 |
Session::~Session() |
1
by brian
clean slate |
374 |
{
|
1377.6.3
by pawel
changed function-like defines into functions in some files |
375 |
this->checkSentry(); |
1
by brian
clean slate |
376 |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
377 |
if (client->isConnected()) |
942.1.2
by Monty Taylor
Started trying to sort out session lifecycle. |
378 |
{
|
379 |
if (global_system_variables.log_warnings) |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
380 |
errmsg_printf(ERRMSG_LVL_WARN, ER(ER_FORCING_CLOSE),internal::my_progname, |
942.1.2
by Monty Taylor
Started trying to sort out session lifecycle. |
381 |
thread_id, |
1273.11.5
by Dennis Schoen
add getSecurityContext() |
382 |
(getSecurityContext().getUser().c_str() ? |
383 |
getSecurityContext().getUser().c_str() : "")); |
|
942.1.2
by Monty Taylor
Started trying to sort out session lifecycle. |
384 |
disconnect(0, false); |
385 |
}
|
|
386 |
||
1
by brian
clean slate |
387 |
/* Close connection */
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
388 |
client->close(); |
389 |
delete client; |
|
971.3.6
by Eric Day
Moved the last of the libdrizzleclient calls into Protocol. |
390 |
|
947
by Brian Aker
Merge fix |
391 |
if (cleanup_done == false) |
1
by brian
clean slate |
392 |
cleanup(); |
393 |
||
1152.1.4
by Brian Aker
Remove wrappers from SE |
394 |
plugin::StorageEngine::closeConnection(this); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
395 |
plugin_sessionvar_cleanup(this); |
1
by brian
clean slate |
396 |
|
1487
by Brian Aker
More updates for memory::Root |
397 |
warn_root.free_root(MYF(0)); |
1
by brian
clean slate |
398 |
mysys_var=0; // Safety (shouldn't be needed) |
520.1.21
by Brian Aker
THD -> Session rename |
399 |
dbug_sentry= Session_SENTRY_GONE; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
400 |
|
1487
by Brian Aker
More updates for memory::Root |
401 |
main_mem_root.free_root(MYF(0)); |
1779
by Brian Aker
Update session/memory to use boost specific. |
402 |
currentMemRoot().release(); |
403 |
currentSession().release(); |
|
942.1.2
by Monty Taylor
Started trying to sort out session lifecycle. |
404 |
|
1316.1.1
by Joe Daly
add plugin handle to logging to indicate when the session destructor is called |
405 |
plugin::Logging::postEndDo(this); |
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
406 |
plugin::EventObserver::deregisterSessionEvents(*this); |
948
by Brian Aker
Restoring code Monty deleted. |
407 |
|
1764.3.6
by Brian Aker
This includes a query_usage table for looking at performance of previous |
408 |
for (PropertyMap::iterator iter= life_properties.begin(); iter != life_properties.end(); iter++) |
409 |
{
|
|
410 |
delete (*iter).second; |
|
411 |
}
|
|
412 |
life_properties.clear(); |
|
1932.3.13
by Brian Aker
Cleanup session ownership rules such that we know exactly when session has |
413 |
|
414 |
#if 0
|
|
415 |
drizzled::util::custom_backtrace();
|
|
416 |
#endif
|
|
1
by brian
clean slate |
417 |
}
|
418 |
||
1921.4.1
by Brian Aker
Adding in support for EXECUTE to have WITH NO RETURN. |
419 |
void Session::setClient(plugin::Client *client_arg) |
420 |
{
|
|
421 |
client= client_arg; |
|
422 |
client->setSession(this); |
|
423 |
}
|
|
424 |
||
1910.2.8
by Brian Aker
Enapsulate Kill. |
425 |
void Session::awake(Session::killed_state_t state_to_set) |
1
by brian
clean slate |
426 |
{
|
1377.6.3
by pawel
changed function-like defines into functions in some files |
427 |
this->checkSentry(); |
1
by brian
clean slate |
428 |
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
429 |
setKilled(state_to_set); |
520.1.21
by Brian Aker
THD -> Session rename |
430 |
if (state_to_set != Session::KILL_QUERY) |
1
by brian
clean slate |
431 |
{
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
432 |
scheduler->killSession(this); |
1126.10.18
by Padraig O'Sullivan
Various small build fixes for when dtrace is enabled. |
433 |
DRIZZLE_CONNECTION_DONE(thread_id); |
1
by brian
clean slate |
434 |
}
|
435 |
if (mysys_var) |
|
436 |
{
|
|
1812.3.7
by Brian Aker
Typdef our lock type. |
437 |
boost_unique_lock_t scopedLock(mysys_var->mutex); |
1
by brian
clean slate |
438 |
/*
|
1786.2.1
by Brian Aker
Current boost work (more conversion). |
439 |
"
|
1
by brian
clean slate |
440 |
This broadcast could be up in the air if the victim thread
|
441 |
exits the cond in the time between read and broadcast, but that is
|
|
442 |
ok since all we want to do is to make the victim thread get out
|
|
443 |
of waiting on current_cond.
|
|
444 |
If we see a non-zero current_cond: it cannot be an old value (because
|
|
445 |
then exit_cond() should have run and it can't because we have mutex); so
|
|
446 |
it is the true value but maybe current_mutex is not yet non-zero (we're
|
|
447 |
in the middle of enter_cond() and there is a "memory order
|
|
448 |
inversion"). So we test the mutex too to not lock 0.
|
|
449 |
||
450 |
Note that there is a small chance we fail to kill. If victim has locked
|
|
451 |
current_mutex, but hasn't yet entered enter_cond() (which means that
|
|
452 |
current_cond and current_mutex are 0), then the victim will not get
|
|
453 |
a signal and it may wait "forever" on the cond (until
|
|
454 |
we issue a second KILL or the status it's waiting for happens).
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
455 |
It's true that we have set its session->killed but it may not
|
1
by brian
clean slate |
456 |
see it immediately and so may have time to reach the cond_wait().
|
457 |
*/
|
|
458 |
if (mysys_var->current_cond && mysys_var->current_mutex) |
|
459 |
{
|
|
1786.2.1
by Brian Aker
Current boost work (more conversion). |
460 |
mysys_var->current_mutex->lock(); |
1798.3.10
by Brian Aker
Remove additional (maybe last of?) native_handle actual calls (safe_mutex is |
461 |
mysys_var->current_cond->notify_all(); |
1786.2.1
by Brian Aker
Current boost work (more conversion). |
462 |
mysys_var->current_mutex->unlock(); |
1
by brian
clean slate |
463 |
}
|
464 |
}
|
|
465 |
}
|
|
466 |
||
467 |
/*
|
|
468 |
Remember the location of thread info, the structure needed for
|
|
1253.1.6
by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace. |
469 |
memory::sql_alloc() and the structure for the net buffer
|
1
by brian
clean slate |
470 |
*/
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
471 |
bool Session::storeGlobals() |
1
by brian
clean slate |
472 |
{
|
473 |
/*
|
|
474 |
Assert that thread_stack is initialized: it's necessary to be able
|
|
475 |
to track stack overrun.
|
|
476 |
*/
|
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
477 |
assert(thread_stack); |
1
by brian
clean slate |
478 |
|
1779
by Brian Aker
Update session/memory to use boost specific. |
479 |
currentSession().release(); |
480 |
currentSession().reset(this); |
|
481 |
||
482 |
currentMemRoot().release(); |
|
483 |
currentMemRoot().reset(&mem_root); |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
484 |
|
1
by brian
clean slate |
485 |
mysys_var=my_thread_var; |
960.1.1
by Monty Taylor
First pass at scheduler plugin. |
486 |
|
1
by brian
clean slate |
487 |
/*
|
488 |
Let mysqld define the thread id (not mysys)
|
|
520.1.21
by Brian Aker
THD -> Session rename |
489 |
This allows us to move Session to different threads if needed.
|
1
by brian
clean slate |
490 |
*/
|
491 |
mysys_var->id= thread_id; |
|
492 |
||
493 |
/*
|
|
520.1.21
by Brian Aker
THD -> Session rename |
494 |
We have to call thr_lock_info_init() again here as Session may have been
|
1
by brian
clean slate |
495 |
created in another thread
|
496 |
*/
|
|
1689.2.12
by Brian Aker
THR_LOCK_INFO::init() <-- encapsulation |
497 |
lock_info.init(); |
498 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
499 |
return false; |
1
by brian
clean slate |
500 |
}
|
501 |
||
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
502 |
/*
|
503 |
Init Session for query processing.
|
|
504 |
This has to be called once before we call mysql_parse.
|
|
505 |
See also comments in session.h.
|
|
506 |
*/
|
|
507 |
||
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
508 |
void Session::prepareForQueries() |
509 |
{
|
|
510 |
if (variables.max_join_size == HA_POS_ERROR) |
|
511 |
options |= OPTION_BIG_SELECTS; |
|
512 |
||
513 |
version= refresh_version; |
|
961.1.4
by Brian Aker
Remove another lock for processlist. |
514 |
set_proc_info(NULL); |
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
515 |
command= COM_SLEEP; |
516 |
set_time(); |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
517 |
|
1485
by Brian Aker
Updates to confine memroot |
518 |
mem_root->reset_root_defaults(variables.query_alloc_block_size, |
519 |
variables.query_prealloc_size); |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
520 |
transaction.xid_state.xid.null(); |
521 |
transaction.xid_state.in_session=1; |
|
1764.3.6
by Brian Aker
This includes a query_usage table for looking at performance of previous |
522 |
if (use_usage) |
523 |
resetUsage(); |
|
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
524 |
}
|
525 |
||
526 |
bool Session::initGlobals() |
|
527 |
{
|
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
528 |
if (storeGlobals()) |
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
529 |
{
|
530 |
disconnect(ER_OUT_OF_RESOURCES, true); |
|
1689.5.1
by Joseph Daly
remove increment calls |
531 |
status_var.aborted_connects++; |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
532 |
return true; |
533 |
}
|
|
534 |
return false; |
|
535 |
}
|
|
536 |
||
537 |
void Session::run() |
|
538 |
{
|
|
539 |
if (initGlobals() || authenticate()) |
|
540 |
{
|
|
541 |
disconnect(0, true); |
|
542 |
return; |
|
543 |
}
|
|
544 |
||
545 |
prepareForQueries(); |
|
546 |
||
1910.2.8
by Brian Aker
Enapsulate Kill. |
547 |
while (not client->haveError() && getKilled() != KILL_CONNECTION) |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
548 |
{
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
549 |
if (not executeStatement()) |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
550 |
break; |
551 |
}
|
|
552 |
||
553 |
disconnect(0, true); |
|
554 |
}
|
|
555 |
||
1932.3.13
by Brian Aker
Cleanup session ownership rules such that we know exactly when session has |
556 |
bool Session::schedule(Session::shared_ptr &arg) |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
557 |
{
|
1932.3.3
by Brian Aker
Pull in code to abstract out the session list a bit. |
558 |
arg->scheduler= plugin::Scheduler::getScheduler(); |
559 |
assert(arg->scheduler); |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
560 |
|
1260.1.2
by Monty Taylor
Replaced operator overloads with methods since we can't actually usefully follow the proper semantics for the operators. |
561 |
connection_count.increment(); |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
562 |
|
1537.2.1
by Joe Daly
add statistics_variables.h |
563 |
if (connection_count > current_global_counters.max_used_connections) |
564 |
{
|
|
565 |
current_global_counters.max_used_connections= connection_count; |
|
566 |
}
|
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
567 |
|
1726.3.3
by LinuxJedi
Add a proper connections counter. |
568 |
current_global_counters.connections++; |
1932.3.3
by Brian Aker
Pull in code to abstract out the session list a bit. |
569 |
arg->thread_id= arg->variables.pseudo_thread_id= global_thread_id++; |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
570 |
|
1932.3.10
by Brian Aker
Modify to use insert inside of session list. |
571 |
session::Cache::singleton().insert(arg); |
1932.3.3
by Brian Aker
Pull in code to abstract out the session list a bit. |
572 |
|
573 |
if (unlikely(plugin::EventObserver::connectSession(*arg))) |
|
574 |
{
|
|
575 |
// We should do something about an error...
|
|
576 |
}
|
|
577 |
||
1932.3.13
by Brian Aker
Cleanup session ownership rules such that we know exactly when session has |
578 |
if (plugin::Scheduler::getScheduler()->addSession(arg)) |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
579 |
{
|
1932.3.11
by Brian Aker
Fix dtrace issue. |
580 |
DRIZZLE_CONNECTION_START(arg->getSessionId()); |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
581 |
char error_message_buff[DRIZZLE_ERRMSG_SIZE]; |
582 |
||
1932.3.3
by Brian Aker
Pull in code to abstract out the session list a bit. |
583 |
arg->setKilled(Session::KILL_CONNECTION); |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
584 |
|
1932.3.3
by Brian Aker
Pull in code to abstract out the session list a bit. |
585 |
arg->status_var.aborted_connects++; |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
586 |
|
587 |
/* Can't use my_error() since store_globals has not been called. */
|
|
588 |
/* TODO replace will better error message */
|
|
589 |
snprintf(error_message_buff, sizeof(error_message_buff), |
|
590 |
ER(ER_CANT_CREATE_THREAD), 1); |
|
1932.3.3
by Brian Aker
Pull in code to abstract out the session list a bit. |
591 |
arg->client->sendError(ER_CANT_CREATE_THREAD, error_message_buff); |
1932.3.11
by Brian Aker
Fix dtrace issue. |
592 |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
593 |
return true; |
594 |
}
|
|
595 |
||
596 |
return false; |
|
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
597 |
}
|
598 |
||
1241.9.55
by Monty Taylor
Moved tree into drizzled/ |
599 |
|
1932.3.3
by Brian Aker
Pull in code to abstract out the session list a bit. |
600 |
/*
|
601 |
Is this session viewable by the current user?
|
|
602 |
*/
|
|
603 |
bool Session::isViewable() const |
|
604 |
{
|
|
605 |
return plugin::Authorization::isAuthorized(current_session->getSecurityContext(), |
|
606 |
this, |
|
607 |
false); |
|
608 |
}
|
|
609 |
||
610 |
||
1812.3.5
by Brian Aker
Move to boost condition_any |
611 |
const char* Session::enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg) |
1241.9.55
by Monty Taylor
Moved tree into drizzled/ |
612 |
{
|
613 |
const char* old_msg = get_proc_info(); |
|
614 |
safe_mutex_assert_owner(mutex); |
|
1786.2.1
by Brian Aker
Current boost work (more conversion). |
615 |
mysys_var->current_mutex = &mutex; |
616 |
mysys_var->current_cond = &cond; |
|
1241.9.55
by Monty Taylor
Moved tree into drizzled/ |
617 |
this->set_proc_info(msg); |
618 |
return old_msg; |
|
619 |
}
|
|
620 |
||
621 |
void Session::exit_cond(const char* old_msg) |
|
622 |
{
|
|
623 |
/*
|
|
624 |
Putting the mutex unlock in exit_cond() ensures that
|
|
625 |
mysys_var->current_mutex is always unlocked _before_ mysys_var->mutex is
|
|
626 |
locked (if that would not be the case, you'll get a deadlock if someone
|
|
627 |
does a Session::awake() on you).
|
|
628 |
*/
|
|
1786.2.1
by Brian Aker
Current boost work (more conversion). |
629 |
mysys_var->current_mutex->unlock(); |
1812.3.7
by Brian Aker
Typdef our lock type. |
630 |
boost_unique_lock_t scopedLock(mysys_var->mutex); |
1241.9.55
by Monty Taylor
Moved tree into drizzled/ |
631 |
mysys_var->current_mutex = 0; |
632 |
mysys_var->current_cond = 0; |
|
633 |
this->set_proc_info(old_msg); |
|
634 |
}
|
|
635 |
||
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
636 |
bool Session::authenticate() |
637 |
{
|
|
1897.1.7
by Brian Aker
Partial encapsulation of lex_start. |
638 |
lex->start(this); |
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
639 |
if (client->authenticate()) |
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
640 |
return false; |
971.3.6
by Eric Day
Moved the last of the libdrizzleclient calls into Protocol. |
641 |
|
1689.5.1
by Joseph Daly
remove increment calls |
642 |
status_var.aborted_connects++; |
1625.2.1
by Joe Daly
initial user stats impl |
643 |
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
644 |
return true; |
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
645 |
}
|
646 |
||
1857.4.1
by Monty Taylor
Added string sys_var type. |
647 |
bool Session::checkUser(const std::string &passwd_str, |
648 |
const std::string &in_db) |
|
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
649 |
{
|
1317.1.3
by Monty Taylor
Fixed Authentication plugin interface to use SecurityContext rather than the |
650 |
bool is_authenticated= |
651 |
plugin::Authentication::isAuthenticated(getSecurityContext(), |
|
652 |
passwd_str); |
|
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
653 |
|
654 |
if (is_authenticated != true) |
|
655 |
{
|
|
1689.5.1
by Joseph Daly
remove increment calls |
656 |
status_var.access_denied++; |
1317.1.3
by Monty Taylor
Fixed Authentication plugin interface to use SecurityContext rather than the |
657 |
/* isAuthenticated has pushed the error message */
|
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
658 |
return false; |
659 |
}
|
|
660 |
||
661 |
/* Change database if necessary */
|
|
1857.4.1
by Monty Taylor
Added string sys_var type. |
662 |
if (not in_db.empty()) |
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
663 |
{
|
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
664 |
SchemaIdentifier identifier(in_db); |
665 |
if (mysql_change_db(this, identifier)) |
|
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
666 |
{
|
667 |
/* mysql_change_db() has pushed the error message. */
|
|
668 |
return false; |
|
669 |
}
|
|
670 |
}
|
|
671 |
my_ok(); |
|
1857.4.1
by Monty Taylor
Added string sys_var type. |
672 |
password= not passwd_str.empty(); |
934.2.4
by Jay Pipes
This changeset pulls check_user(), check_connection(), and login_connection() out of sql_connect.cc and makes them member methods of Session, where they belong. Also, made sure that functions that return a bool return true when it succeeds, and not false... |
673 |
|
674 |
/* Ready to handle queries */
|
|
675 |
return true; |
|
676 |
}
|
|
1
by brian
clean slate |
677 |
|
934.2.8
by Jay Pipes
Refactors the do_command() function out of the sql_parse.cc stuff and implements it as a member method, executeStatement() on the Session object. |
678 |
bool Session::executeStatement() |
679 |
{
|
|
680 |
char *l_packet= 0; |
|
681 |
uint32_t packet_length; |
|
682 |
||
683 |
enum enum_server_command l_command; |
|
684 |
||
685 |
/*
|
|
686 |
indicator of uninitialized lex => normal flow of errors handling
|
|
687 |
(see my_message_sql)
|
|
688 |
*/
|
|
689 |
lex->current_select= 0; |
|
971.6.7
by Eric Day
Reworked listen interface to not require binding of TCP ports. |
690 |
clear_error(); |
691 |
main_da.reset_diagnostics_area(); |
|
934.2.8
by Jay Pipes
Refactors the do_command() function out of the sql_parse.cc stuff and implements it as a member method, executeStatement() on the Session object. |
692 |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
693 |
if (client->readCommand(&l_packet, &packet_length) == false) |
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
694 |
{
|
971.3.6
by Eric Day
Moved the last of the libdrizzleclient calls into Protocol. |
695 |
return false; |
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
696 |
}
|
971.3.6
by Eric Day
Moved the last of the libdrizzleclient calls into Protocol. |
697 |
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
698 |
if (getKilled() == KILL_CONNECTION) |
1724.4.2
by LinuxJedi
Fix "server gone away" in drizzle client. After a connection is killed it can execute one query afterwards, which can give rubbish back. Now check if we are killed after readCommand. |
699 |
return false; |
700 |
||
971.3.6
by Eric Day
Moved the last of the libdrizzleclient calls into Protocol. |
701 |
if (packet_length == 0) |
702 |
return true; |
|
934.2.8
by Jay Pipes
Refactors the do_command() function out of the sql_parse.cc stuff and implements it as a member method, executeStatement() on the Session object. |
703 |
|
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
704 |
l_command= static_cast<enum_server_command>(l_packet[0]); |
934.2.8
by Jay Pipes
Refactors the do_command() function out of the sql_parse.cc stuff and implements it as a member method, executeStatement() on the Session object. |
705 |
|
706 |
if (command >= COM_END) |
|
707 |
command= COM_END; // Wrong command |
|
708 |
||
709 |
assert(packet_length); |
|
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
710 |
return not dispatch_command(l_command, this, l_packet+1, (uint32_t) (packet_length-1)); |
934.2.8
by Jay Pipes
Refactors the do_command() function out of the sql_parse.cc stuff and implements it as a member method, executeStatement() on the Session object. |
711 |
}
|
934.2.9
by Jay Pipes
Pulls alloc_query() C function out of sql_parse.cc and adds readAndStoreQuery() member method of Session class. |
712 |
|
713 |
bool Session::readAndStoreQuery(const char *in_packet, uint32_t in_packet_length) |
|
714 |
{
|
|
715 |
/* Remove garbage at start and end of query */
|
|
716 |
while (in_packet_length > 0 && my_isspace(charset(), in_packet[0])) |
|
717 |
{
|
|
718 |
in_packet++; |
|
719 |
in_packet_length--; |
|
720 |
}
|
|
721 |
const char *pos= in_packet + in_packet_length; /* Point at end null */ |
|
1921.4.13
by Brian Aker
Fix issue where session info might not be correct. |
722 |
while (in_packet_length > 0 && (pos[-1] == ';' || my_isspace(charset() ,pos[-1]))) |
934.2.9
by Jay Pipes
Pulls alloc_query() C function out of sql_parse.cc and adds readAndStoreQuery() member method of Session class. |
723 |
{
|
724 |
pos--; |
|
725 |
in_packet_length--; |
|
726 |
}
|
|
727 |
||
1921.4.13
by Brian Aker
Fix issue where session info might not be correct. |
728 |
query.reset(new std::string(in_packet, in_packet + in_packet_length)); |
934.2.9
by Jay Pipes
Pulls alloc_query() C function out of sql_parse.cc and adds readAndStoreQuery() member method of Session class. |
729 |
|
730 |
return true; |
|
731 |
}
|
|
732 |
||
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
733 |
bool Session::endTransaction(enum enum_mysql_completiontype completion) |
734 |
{
|
|
735 |
bool do_release= 0; |
|
736 |
bool result= true; |
|
1273.1.2
by Jay Pipes
This patch does not change any algorithms or code paths, |
737 |
TransactionServices &transaction_services= TransactionServices::singleton(); |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
738 |
|
739 |
if (transaction.xid_state.xa_state != XA_NOTR) |
|
740 |
{
|
|
741 |
my_error(ER_XAER_RMFAIL, MYF(0), xa_state_names[transaction.xid_state.xa_state]); |
|
742 |
return false; |
|
743 |
}
|
|
971.3.64
by Eric Day
Cleaned up Scheduler plugin, moved more code to the schedular plugins, reworked some functions to be methods in Session, removed some dead code. |
744 |
switch (completion) |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
745 |
{
|
746 |
case COMMIT: |
|
747 |
/*
|
|
748 |
* We don't use endActiveTransaction() here to ensure that this works
|
|
749 |
* even if there is a problem with the OPTION_AUTO_COMMIT flag
|
|
750 |
* (Which of course should never happen...)
|
|
751 |
*/
|
|
752 |
server_status&= ~SERVER_STATUS_IN_TRANS; |
|
1405.3.5
by Jay Pipes
TransactionServices method names now meet code style guidelines. |
753 |
if (transaction_services.commitTransaction(this, true)) |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
754 |
result= false; |
1172.1.2
by Brian Aker
Remove worthless call (ok... for not current replication system). |
755 |
options&= ~(OPTION_BEGIN); |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
756 |
break; |
757 |
case COMMIT_RELEASE: |
|
758 |
do_release= 1; /* fall through */ |
|
759 |
case COMMIT_AND_CHAIN: |
|
760 |
result= endActiveTransaction(); |
|
761 |
if (result == true && completion == COMMIT_AND_CHAIN) |
|
762 |
result= startTransaction(); |
|
763 |
break; |
|
764 |
case ROLLBACK_RELEASE: |
|
765 |
do_release= 1; /* fall through */ |
|
766 |
case ROLLBACK: |
|
767 |
case ROLLBACK_AND_CHAIN: |
|
768 |
{
|
|
769 |
server_status&= ~SERVER_STATUS_IN_TRANS; |
|
1405.3.5
by Jay Pipes
TransactionServices method names now meet code style guidelines. |
770 |
if (transaction_services.rollbackTransaction(this, true)) |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
771 |
result= false; |
1172.1.2
by Brian Aker
Remove worthless call (ok... for not current replication system). |
772 |
options&= ~(OPTION_BEGIN); |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
773 |
if (result == true && (completion == ROLLBACK_AND_CHAIN)) |
774 |
result= startTransaction(); |
|
775 |
break; |
|
776 |
}
|
|
777 |
default: |
|
778 |
my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); |
|
779 |
return false; |
|
780 |
}
|
|
781 |
||
782 |
if (result == false) |
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
783 |
{
|
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
784 |
my_error(killed_errno(), MYF(0)); |
1910.2.8
by Brian Aker
Enapsulate Kill. |
785 |
}
|
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
786 |
else if ((result == true) && do_release) |
1910.2.8
by Brian Aker
Enapsulate Kill. |
787 |
{
|
788 |
setKilled(Session::KILL_CONNECTION); |
|
789 |
}
|
|
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
790 |
|
791 |
return result; |
|
792 |
}
|
|
793 |
||
794 |
bool Session::endActiveTransaction() |
|
795 |
{
|
|
796 |
bool result= true; |
|
1273.1.2
by Jay Pipes
This patch does not change any algorithms or code paths, |
797 |
TransactionServices &transaction_services= TransactionServices::singleton(); |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
798 |
|
799 |
if (transaction.xid_state.xa_state != XA_NOTR) |
|
800 |
{
|
|
801 |
my_error(ER_XAER_RMFAIL, MYF(0), xa_state_names[transaction.xid_state.xa_state]); |
|
802 |
return false; |
|
803 |
}
|
|
1054.1.8
by Brian Aker
Remove lock_tables list from session. |
804 |
if (options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
805 |
{
|
806 |
server_status&= ~SERVER_STATUS_IN_TRANS; |
|
1405.3.5
by Jay Pipes
TransactionServices method names now meet code style guidelines. |
807 |
if (transaction_services.commitTransaction(this, true)) |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
808 |
result= false; |
809 |
}
|
|
1172.1.2
by Brian Aker
Remove worthless call (ok... for not current replication system). |
810 |
options&= ~(OPTION_BEGIN); |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
811 |
return result; |
812 |
}
|
|
813 |
||
1206.1.3
by Brian Aker
Valgrind fix for startTransaction() |
814 |
bool Session::startTransaction(start_transaction_option_t opt) |
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
815 |
{
|
816 |
bool result= true; |
|
817 |
||
818 |
if (! endActiveTransaction()) |
|
1206.1.3
by Brian Aker
Valgrind fix for startTransaction() |
819 |
{
|
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
820 |
result= false; |
1206.1.3
by Brian Aker
Valgrind fix for startTransaction() |
821 |
}
|
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
822 |
else
|
823 |
{
|
|
824 |
options|= OPTION_BEGIN; |
|
825 |
server_status|= SERVER_STATUS_IN_TRANS; |
|
1206.1.3
by Brian Aker
Valgrind fix for startTransaction() |
826 |
|
1273.1.27
by Jay Pipes
Completes the work of removing the weirdness around transaction |
827 |
if (plugin::TransactionalStorageEngine::notifyStartTransaction(this, opt)) |
1206.1.3
by Brian Aker
Valgrind fix for startTransaction() |
828 |
{
|
1273.1.27
by Jay Pipes
Completes the work of removing the weirdness around transaction |
829 |
result= false; |
1206.1.3
by Brian Aker
Valgrind fix for startTransaction() |
830 |
}
|
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
831 |
}
|
1206.1.3
by Brian Aker
Valgrind fix for startTransaction() |
832 |
|
934.2.11
by Jay Pipes
Moves end_trans(), begin_trans(), end_active_trans() out of the parser module and adds startTransaction(), endTransaction(), and endActiveTransaction() member methods of Session object. |
833 |
return result; |
834 |
}
|
|
835 |
||
520.1.21
by Brian Aker
THD -> Session rename |
836 |
void Session::cleanup_after_query() |
1
by brian
clean slate |
837 |
{
|
838 |
/*
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
839 |
Reset rand_used so that detection of calls to rand() will save random
|
1
by brian
clean slate |
840 |
seeds if needed by the slave.
|
841 |
*/
|
|
842 |
{
|
|
843 |
/* Forget those values, for next binlogger: */
|
|
844 |
auto_inc_intervals_in_cur_stmt_for_binlog.empty(); |
|
845 |
}
|
|
846 |
if (first_successful_insert_id_in_cur_stmt > 0) |
|
847 |
{
|
|
848 |
/* set what LAST_INSERT_ID() will return */
|
|
1055.2.17
by Jay Pipes
More style cleanups in Session |
849 |
first_successful_insert_id_in_prev_stmt= first_successful_insert_id_in_cur_stmt; |
1
by brian
clean slate |
850 |
first_successful_insert_id_in_cur_stmt= 0; |
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
851 |
substitute_null_with_insert_id= true; |
1
by brian
clean slate |
852 |
}
|
1055.2.17
by Jay Pipes
More style cleanups in Session |
853 |
arg_of_last_insert_id_function= false; |
1
by brian
clean slate |
854 |
/* Free Items that were created during this execution */
|
855 |
free_items(); |
|
856 |
/* Reset where. */
|
|
520.1.21
by Brian Aker
THD -> Session rename |
857 |
where= Session::DEFAULT_WHERE; |
1532.1.1
by Brian Aker
Merge of change to flip table instance to be share instance |
858 |
|
859 |
/* Reset the temporary shares we built */
|
|
1843.8.4
by Brian Aker
Committing refactor of table out (this is part of the concurrency work). |
860 |
for_each(temporary_shares.begin(), |
861 |
temporary_shares.end(), |
|
862 |
DeletePtr()); |
|
1532.1.1
by Brian Aker
Merge of change to flip table instance to be share instance |
863 |
temporary_shares.clear(); |
1
by brian
clean slate |
864 |
}
|
865 |
||
866 |
/**
|
|
867 |
Create a LEX_STRING in this connection.
|
|
868 |
||
869 |
@param lex_str pointer to LEX_STRING object to be initialized
|
|
870 |
@param str initializer to be copied into lex_str
|
|
871 |
@param length length of str, in bytes
|
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
872 |
@param allocate_lex_string if true, allocate new LEX_STRING object,
|
1
by brian
clean slate |
873 |
instead of using lex_str value
|
874 |
@return NULL on failure, or pointer to the LEX_STRING object
|
|
875 |
*/
|
|
520.1.21
by Brian Aker
THD -> Session rename |
876 |
LEX_STRING *Session::make_lex_string(LEX_STRING *lex_str, |
1273.13.38
by Brian Aker
Add in new show work. |
877 |
const std::string &str, |
878 |
bool allocate_lex_string) |
|
879 |
{
|
|
880 |
return make_lex_string(lex_str, str.c_str(), str.length(), allocate_lex_string); |
|
881 |
}
|
|
882 |
||
883 |
LEX_STRING *Session::make_lex_string(LEX_STRING *lex_str, |
|
884 |
const char* str, uint32_t length, |
|
885 |
bool allocate_lex_string) |
|
1
by brian
clean slate |
886 |
{
|
887 |
if (allocate_lex_string) |
|
888 |
if (!(lex_str= (LEX_STRING *)alloc(sizeof(LEX_STRING)))) |
|
889 |
return 0; |
|
1487
by Brian Aker
More updates for memory::Root |
890 |
if (!(lex_str->str= mem_root->strmake_root(str, length))) |
1
by brian
clean slate |
891 |
return 0; |
892 |
lex_str->length= length; |
|
893 |
return lex_str; |
|
894 |
}
|
|
895 |
||
520.1.21
by Brian Aker
THD -> Session rename |
896 |
int Session::send_explain_fields(select_result *result) |
1
by brian
clean slate |
897 |
{
|
898 |
List<Item> field_list; |
|
899 |
Item *item; |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
900 |
const CHARSET_INFO * const cs= system_charset_info; |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
901 |
field_list.push_back(new Item_return_int("id",3, DRIZZLE_TYPE_LONGLONG)); |
1
by brian
clean slate |
902 |
field_list.push_back(new Item_empty_string("select_type", 19, cs)); |
903 |
field_list.push_back(item= new Item_empty_string("table", NAME_CHAR_LEN, cs)); |
|
904 |
item->maybe_null= 1; |
|
905 |
field_list.push_back(item= new Item_empty_string("type", 10, cs)); |
|
906 |
item->maybe_null= 1; |
|
907 |
field_list.push_back(item=new Item_empty_string("possible_keys", |
|
908 |
NAME_CHAR_LEN*MAX_KEY, cs)); |
|
909 |
item->maybe_null=1; |
|
910 |
field_list.push_back(item=new Item_empty_string("key", NAME_CHAR_LEN, cs)); |
|
911 |
item->maybe_null=1; |
|
912 |
field_list.push_back(item= |
|
913 |
new Item_empty_string("key_len", |
|
914 |
MAX_KEY * |
|
915 |
(MAX_KEY_LENGTH_DECIMAL_WIDTH + 1 /* for comma */), |
|
916 |
cs)); |
|
917 |
item->maybe_null=1; |
|
918 |
field_list.push_back(item=new Item_empty_string("ref", |
|
919 |
NAME_CHAR_LEN*MAX_REF_PARTS, |
|
920 |
cs)); |
|
921 |
item->maybe_null=1; |
|
922 |
field_list.push_back(item= new Item_return_int("rows", 10, |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
923 |
DRIZZLE_TYPE_LONGLONG)); |
1
by brian
clean slate |
924 |
if (lex->describe & DESCRIBE_EXTENDED) |
925 |
{
|
|
926 |
field_list.push_back(item= new Item_float("filtered", 0.1234, 2, 4)); |
|
927 |
item->maybe_null=1; |
|
928 |
}
|
|
929 |
item->maybe_null= 1; |
|
930 |
field_list.push_back(new Item_empty_string("Extra", 255, cs)); |
|
971.3.63
by Eric Day
Removed protocol field flags. |
931 |
return (result->send_fields(field_list)); |
1
by brian
clean slate |
932 |
}
|
933 |
||
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
934 |
void select_result::send_error(uint32_t errcode, const char *err) |
935 |
{
|
|
936 |
my_message(errcode, err, MYF(0)); |
|
937 |
}
|
|
938 |
||
1
by brian
clean slate |
939 |
/************************************************************************
|
940 |
Handling writing to file
|
|
941 |
************************************************************************/
|
|
942 |
||
482
by Brian Aker
Remove uint. |
943 |
void select_to_file::send_error(uint32_t errcode,const char *err) |
1
by brian
clean slate |
944 |
{
|
945 |
my_message(errcode, err, MYF(0)); |
|
946 |
if (file > 0) |
|
947 |
{
|
|
1909.1.1
by Brian Aker
Encapsulation of IO_CACHE. |
948 |
(void) cache->end_io_cache(); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
949 |
(void) internal::my_close(file, MYF(0)); |
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
950 |
(void) internal::my_delete(path.file_string().c_str(), MYF(0)); // Delete file on error |
1
by brian
clean slate |
951 |
file= -1; |
952 |
}
|
|
953 |
}
|
|
954 |
||
955 |
||
956 |
bool select_to_file::send_eof() |
|
957 |
{
|
|
1909.1.1
by Brian Aker
Encapsulation of IO_CACHE. |
958 |
int error= test(cache->end_io_cache()); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
959 |
if (internal::my_close(file, MYF(MY_WME))) |
1
by brian
clean slate |
960 |
error= 1; |
961 |
if (!error) |
|
962 |
{
|
|
963 |
/*
|
|
964 |
In order to remember the value of affected rows for ROW_COUNT()
|
|
965 |
function, SELECT INTO has to have an own SQLCOM.
|
|
966 |
TODO: split from SQLCOM_SELECT
|
|
967 |
*/
|
|
836
by Brian Aker
Fixed session call from function to method. |
968 |
session->my_ok(row_count); |
1
by brian
clean slate |
969 |
}
|
970 |
file= -1; |
|
971 |
return error; |
|
972 |
}
|
|
973 |
||
974 |
||
975 |
void select_to_file::cleanup() |
|
976 |
{
|
|
977 |
/* In case of error send_eof() may be not called: close the file here. */
|
|
978 |
if (file >= 0) |
|
979 |
{
|
|
1909.1.1
by Brian Aker
Encapsulation of IO_CACHE. |
980 |
(void) cache->end_io_cache(); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
981 |
(void) internal::my_close(file, MYF(0)); |
1
by brian
clean slate |
982 |
file= -1; |
983 |
}
|
|
1813.2.14
by Monty Taylor
Removed API element that SuSE and some older boosts don't have. |
984 |
path= ""; |
1
by brian
clean slate |
985 |
row_count= 0; |
986 |
}
|
|
987 |
||
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
988 |
select_to_file::select_to_file(file_exchange *ex) |
1241.9.52
by Monty Taylor
Fixed valgrind issue. |
989 |
: exchange(ex), |
990 |
file(-1), |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
991 |
cache(static_cast<internal::IO_CACHE *>(memory::sql_calloc(sizeof(internal::IO_CACHE)))), |
1241.9.52
by Monty Taylor
Fixed valgrind issue. |
992 |
row_count(0L) |
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
993 |
{
|
1813.2.14
by Monty Taylor
Removed API element that SuSE and some older boosts don't have. |
994 |
path= ""; |
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
995 |
}
|
1
by brian
clean slate |
996 |
|
997 |
select_to_file::~select_to_file() |
|
998 |
{
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
999 |
cleanup(); |
1
by brian
clean slate |
1000 |
}
|
1001 |
||
1002 |
/***************************************************************************
|
|
1003 |
** Export of select to textfile
|
|
1004 |
***************************************************************************/
|
|
1005 |
||
1006 |
select_export::~select_export() |
|
1007 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1008 |
session->sent_row_count=row_count; |
1
by brian
clean slate |
1009 |
}
|
1010 |
||
1011 |
||
1012 |
/*
|
|
1013 |
Create file with IO cache
|
|
1014 |
||
1015 |
SYNOPSIS
|
|
1016 |
create_file()
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1017 |
session Thread handle
|
1
by brian
clean slate |
1018 |
path File name
|
1019 |
exchange Excange class
|
|
1020 |
cache IO cache
|
|
1021 |
||
1022 |
RETURN
|
|
1023 |
>= 0 File handle
|
|
1024 |
-1 Error
|
|
1025 |
*/
|
|
1026 |
||
1027 |
||
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1028 |
static int create_file(Session *session, |
1029 |
fs::path &target_path, |
|
1030 |
file_exchange *exchange, |
|
1031 |
internal::IO_CACHE *cache) |
|
1
by brian
clean slate |
1032 |
{
|
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1033 |
fs::path to_file(exchange->file_name); |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
1034 |
int file; |
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1035 |
|
1036 |
if (not to_file.has_root_directory()) |
|
1
by brian
clean slate |
1037 |
{
|
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1038 |
target_path= fs::system_complete(getDataHomeCatalog()); |
1039 |
if (not session->db.empty()) |
|
1040 |
{
|
|
1041 |
int count_elements= 0; |
|
1042 |
for (fs::path::iterator iter= to_file.begin(); |
|
1043 |
iter != to_file.end(); |
|
1044 |
++iter, ++count_elements) |
|
1045 |
{ } |
|
1046 |
||
1047 |
if (count_elements == 1) |
|
1048 |
{
|
|
1049 |
target_path /= session->db; |
|
1050 |
}
|
|
1051 |
}
|
|
1052 |
target_path /= to_file; |
|
1
by brian
clean slate |
1053 |
}
|
1054 |
else
|
|
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1055 |
{
|
1056 |
target_path = exchange->file_name; |
|
1057 |
}
|
|
1
by brian
clean slate |
1058 |
|
1813.2.6
by Monty Taylor
Made secure_file_priv be an fs::path from the beginning. |
1059 |
if (not secure_file_priv.string().empty()) |
1
by brian
clean slate |
1060 |
{
|
1813.2.10
by Monty Taylor
Expand secure-file-priv once at startup rather than on each path check. |
1061 |
if (target_path.file_string().substr(0, secure_file_priv.file_string().size()) != secure_file_priv.file_string()) |
1786.3.2
by Monty Taylor
Cleaned up the initial pass at this. It's not perfect, but it does work. |
1062 |
{
|
1063 |
/* Write only allowed to dir or subdir specified by secure_file_priv */
|
|
1064 |
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); |
|
1065 |
return -1; |
|
1066 |
}
|
|
1
by brian
clean slate |
1067 |
}
|
1068 |
||
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1069 |
if (!access(target_path.file_string().c_str(), F_OK)) |
1
by brian
clean slate |
1070 |
{
|
1071 |
my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name); |
|
1072 |
return -1; |
|
1073 |
}
|
|
1074 |
/* Create the file world readable */
|
|
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1075 |
if ((file= internal::my_create(target_path.file_string().c_str(), 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0) |
1
by brian
clean slate |
1076 |
return file; |
1077 |
(void) fchmod(file, 0666); // Because of umask() |
|
1909.1.1
by Brian Aker
Encapsulation of IO_CACHE. |
1078 |
if (cache->init_io_cache(file, 0L, internal::WRITE_CACHE, 0L, 1, MYF(MY_WME))) |
1
by brian
clean slate |
1079 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1080 |
internal::my_close(file, MYF(0)); |
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1081 |
internal::my_delete(target_path.file_string().c_str(), MYF(0)); // Delete file on error, it was just created |
1
by brian
clean slate |
1082 |
return -1; |
1083 |
}
|
|
1084 |
return file; |
|
1085 |
}
|
|
1086 |
||
1087 |
||
1088 |
int
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1089 |
select_export::prepare(List<Item> &list, Select_Lex_Unit *u) |
1
by brian
clean slate |
1090 |
{
|
1091 |
bool blob_flag=0; |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1092 |
bool string_results= false, non_string_results= false; |
1
by brian
clean slate |
1093 |
unit= u; |
895
by Brian Aker
Completion (?) of uint conversion. |
1094 |
if ((uint32_t) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN) |
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1095 |
{
|
1096 |
path= exchange->file_name; |
|
1097 |
}
|
|
1
by brian
clean slate |
1098 |
|
1099 |
/* Check if there is any blobs in data */
|
|
1100 |
{
|
|
1101 |
List_iterator_fast<Item> li(list); |
|
1102 |
Item *item; |
|
1103 |
while ((item=li++)) |
|
1104 |
{
|
|
1105 |
if (item->max_length >= MAX_BLOB_WIDTH) |
|
1106 |
{
|
|
1107 |
blob_flag=1; |
|
1108 |
break; |
|
1109 |
}
|
|
1110 |
if (item->result_type() == STRING_RESULT) |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1111 |
string_results= true; |
1
by brian
clean slate |
1112 |
else
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1113 |
non_string_results= true; |
1
by brian
clean slate |
1114 |
}
|
1115 |
}
|
|
1116 |
field_term_length=exchange->field_term->length(); |
|
1117 |
field_term_char= field_term_length ? |
|
481
by Brian Aker
Remove all of uchar. |
1118 |
(int) (unsigned char) (*exchange->field_term)[0] : INT_MAX; |
1
by brian
clean slate |
1119 |
if (!exchange->line_term->length()) |
1120 |
exchange->line_term=exchange->field_term; // Use this if it exists |
|
1121 |
field_sep_char= (exchange->enclosed->length() ? |
|
481
by Brian Aker
Remove all of uchar. |
1122 |
(int) (unsigned char) (*exchange->enclosed)[0] : field_term_char); |
1
by brian
clean slate |
1123 |
escape_char= (exchange->escaped->length() ? |
481
by Brian Aker
Remove all of uchar. |
1124 |
(int) (unsigned char) (*exchange->escaped)[0] : -1); |
1
by brian
clean slate |
1125 |
is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char)); |
1126 |
is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char)); |
|
1127 |
line_sep_char= (exchange->line_term->length() ? |
|
481
by Brian Aker
Remove all of uchar. |
1128 |
(int) (unsigned char) (*exchange->line_term)[0] : INT_MAX); |
1
by brian
clean slate |
1129 |
if (!field_term_length) |
1130 |
exchange->opt_enclosed=0; |
|
1131 |
if (!exchange->enclosed->length()) |
|
1132 |
exchange->opt_enclosed=1; // A little quicker loop |
|
1133 |
fixed_row_size= (!field_term_length && !exchange->enclosed->length() && |
|
1134 |
!blob_flag); |
|
1135 |
if ((is_ambiguous_field_sep && exchange->enclosed->is_empty() && |
|
1136 |
(string_results || is_unsafe_field_sep)) || |
|
1137 |
(exchange->opt_enclosed && non_string_results && |
|
1138 |
field_term_length && strchr(NUMERIC_CHARS, field_term_char))) |
|
1139 |
{
|
|
673.3.8
by Stewart Smith
fix outfile_loaddata test for drizzle. |
1140 |
my_error(ER_AMBIGUOUS_FIELD_TERM, MYF(0)); |
1141 |
return 1; |
|
1
by brian
clean slate |
1142 |
}
|
673.3.8
by Stewart Smith
fix outfile_loaddata test for drizzle. |
1143 |
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1144 |
if ((file= create_file(session, path, exchange, cache)) < 0) |
673.3.8
by Stewart Smith
fix outfile_loaddata test for drizzle. |
1145 |
return 1; |
1
by brian
clean slate |
1146 |
|
1147 |
return 0; |
|
1148 |
}
|
|
1149 |
||
1150 |
bool select_export::send_data(List<Item> &items) |
|
1151 |
{
|
|
1152 |
char buff[MAX_FIELD_WIDTH],null_buff[2],space[MAX_FIELD_WIDTH]; |
|
1153 |
bool space_inited=0; |
|
1154 |
String tmp(buff,sizeof(buff),&my_charset_bin),*res; |
|
1155 |
tmp.length(0); |
|
1156 |
||
1157 |
if (unit->offset_limit_cnt) |
|
1158 |
{ // using limit offset,count |
|
1159 |
unit->offset_limit_cnt--; |
|
1864.3.18
by Brian Aker
REmove goto from session. |
1160 |
return false; |
1
by brian
clean slate |
1161 |
}
|
1162 |
row_count++; |
|
1163 |
Item *item; |
|
482
by Brian Aker
Remove uint. |
1164 |
uint32_t used_length=0,items_left=items.elements; |
1
by brian
clean slate |
1165 |
List_iterator_fast<Item> li(items); |
1166 |
||
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1167 |
if (my_b_write(cache,(unsigned char*) exchange->line_start->ptr(), |
1208.3.2
by brian
Update for Cursor renaming. |
1168 |
exchange->line_start->length())) |
1864.3.18
by Brian Aker
REmove goto from session. |
1169 |
return true; |
1170 |
||
1
by brian
clean slate |
1171 |
while ((item=li++)) |
1172 |
{
|
|
1173 |
Item_result result_type=item->result_type(); |
|
1174 |
bool enclosed = (exchange->enclosed->length() && |
|
1175 |
(!exchange->opt_enclosed || result_type == STRING_RESULT)); |
|
1176 |
res=item->str_result(&tmp); |
|
1177 |
if (res && enclosed) |
|
1178 |
{
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1179 |
if (my_b_write(cache,(unsigned char*) exchange->enclosed->ptr(), |
1208.3.2
by brian
Update for Cursor renaming. |
1180 |
exchange->enclosed->length())) |
1864.3.18
by Brian Aker
REmove goto from session. |
1181 |
return true; |
1
by brian
clean slate |
1182 |
}
|
1183 |
if (!res) |
|
1184 |
{ // NULL |
|
1185 |
if (!fixed_row_size) |
|
1186 |
{
|
|
1208.3.2
by brian
Update for Cursor renaming. |
1187 |
if (escape_char != -1) // Use \N syntax |
1188 |
{
|
|
1189 |
null_buff[0]=escape_char; |
|
1190 |
null_buff[1]='N'; |
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1191 |
if (my_b_write(cache,(unsigned char*) null_buff,2)) |
1864.3.18
by Brian Aker
REmove goto from session. |
1192 |
return true; |
1208.3.2
by brian
Update for Cursor renaming. |
1193 |
}
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1194 |
else if (my_b_write(cache,(unsigned char*) "NULL",4)) |
1864.3.18
by Brian Aker
REmove goto from session. |
1195 |
return true; |
1
by brian
clean slate |
1196 |
}
|
1197 |
else
|
|
1198 |
{
|
|
1208.3.2
by brian
Update for Cursor renaming. |
1199 |
used_length=0; // Fill with space |
1
by brian
clean slate |
1200 |
}
|
1201 |
}
|
|
1202 |
else
|
|
1203 |
{
|
|
1204 |
if (fixed_row_size) |
|
1816.3.1
by Brian Aker
Convert sql_string to use size_t (this should clean up ICC warnings). |
1205 |
used_length= min(res->length(), static_cast<size_t>(item->max_length)); |
1
by brian
clean slate |
1206 |
else
|
1067.4.1
by Nathan Williams
First few changes at converting cmin to std::min. |
1207 |
used_length= res->length(); |
1208 |
||
1
by brian
clean slate |
1209 |
if ((result_type == STRING_RESULT || is_unsafe_field_sep) && |
1208.3.2
by brian
Update for Cursor renaming. |
1210 |
escape_char != -1) |
1
by brian
clean slate |
1211 |
{
|
1212 |
char *pos, *start, *end; |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1213 |
const CHARSET_INFO * const res_charset= res->charset(); |
748
by Brian Aker
Removal of client side collation. |
1214 |
const CHARSET_INFO * const character_set_client= default_charset_info; |
1215 |
||
1
by brian
clean slate |
1216 |
bool check_second_byte= (res_charset == &my_charset_bin) && |
1208.3.2
by brian
Update for Cursor renaming. |
1217 |
character_set_client-> |
1218 |
escape_with_backslash_is_dangerous; |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1219 |
assert(character_set_client->mbmaxlen == 2 || |
748
by Brian Aker
Removal of client side collation. |
1220 |
!character_set_client->escape_with_backslash_is_dangerous); |
1208.3.2
by brian
Update for Cursor renaming. |
1221 |
for (start=pos=(char*) res->ptr(),end=pos+used_length ; |
1222 |
pos != end ; |
|
1223 |
pos++) |
|
1224 |
{
|
|
1225 |
if (use_mb(res_charset)) |
|
1226 |
{
|
|
1227 |
int l; |
|
1228 |
if ((l=my_ismbchar(res_charset, pos, end))) |
|
1229 |
{
|
|
1230 |
pos += l-1; |
|
1231 |
continue; |
|
1232 |
}
|
|
1233 |
}
|
|
1
by brian
clean slate |
1234 |
|
1235 |
/*
|
|
1236 |
Special case when dumping BINARY/VARBINARY/BLOB values
|
|
1237 |
for the clients with character sets big5, cp932, gbk and sjis,
|
|
1238 |
which can have the escape character (0x5C "\" by default)
|
|
1239 |
as the second byte of a multi-byte sequence.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1240 |
|
1
by brian
clean slate |
1241 |
If
|
1242 |
- pos[0] is a valid multi-byte head (e.g 0xEE) and
|
|
1243 |
- pos[1] is 0x00, which will be escaped as "\0",
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1244 |
|
1
by brian
clean slate |
1245 |
then we'll get "0xEE + 0x5C + 0x30" in the output file.
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1246 |
|
1
by brian
clean slate |
1247 |
If this file is later loaded using this sequence of commands:
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1248 |
|
1
by brian
clean slate |
1249 |
mysql> create table t1 (a varchar(128)) character set big5;
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1250 |
mysql> LOAD DATA INFILE 'dump.txt' INTO Table t1;
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1251 |
|
1
by brian
clean slate |
1252 |
then 0x5C will be misinterpreted as the second byte
|
1253 |
of a multi-byte character "0xEE + 0x5C", instead of
|
|
1254 |
escape character for 0x00.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1255 |
|
1
by brian
clean slate |
1256 |
To avoid this confusion, we'll escape the multi-byte
|
1257 |
head character too, so the sequence "0xEE + 0x00" will be
|
|
1258 |
dumped as "0x5C + 0xEE + 0x5C + 0x30".
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1259 |
|
1
by brian
clean slate |
1260 |
Note, in the condition below we only check if
|
1261 |
mbcharlen is equal to 2, because there are no
|
|
1262 |
character sets with mbmaxlen longer than 2
|
|
1263 |
and with escape_with_backslash_is_dangerous set.
|
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1264 |
assert before the loop makes that sure.
|
1
by brian
clean slate |
1265 |
*/
|
1266 |
||
1377.6.3
by pawel
changed function-like defines into functions in some files |
1267 |
if ((needs_escaping(*pos, enclosed) || |
1
by brian
clean slate |
1268 |
(check_second_byte && |
481
by Brian Aker
Remove all of uchar. |
1269 |
my_mbcharlen(character_set_client, (unsigned char) *pos) == 2 && |
1
by brian
clean slate |
1270 |
pos + 1 < end && |
1377.6.3
by pawel
changed function-like defines into functions in some files |
1271 |
needs_escaping(pos[1], enclosed))) && |
1
by brian
clean slate |
1272 |
/*
|
1208.3.2
by brian
Update for Cursor renaming. |
1273 |
Don't escape field_term_char by doubling - doubling is only
|
1274 |
valid for ENCLOSED BY characters:
|
|
1
by brian
clean slate |
1275 |
*/
|
1276 |
(enclosed || !is_ambiguous_field_term || |
|
481
by Brian Aker
Remove all of uchar. |
1277 |
(int) (unsigned char) *pos != field_term_char)) |
1
by brian
clean slate |
1278 |
{
|
1208.3.2
by brian
Update for Cursor renaming. |
1279 |
char tmp_buff[2]; |
481
by Brian Aker
Remove all of uchar. |
1280 |
tmp_buff[0]= ((int) (unsigned char) *pos == field_sep_char && |
1
by brian
clean slate |
1281 |
is_ambiguous_field_sep) ? |
1208.3.2
by brian
Update for Cursor renaming. |
1282 |
field_sep_char : escape_char; |
1283 |
tmp_buff[1]= *pos ? *pos : '0'; |
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1284 |
if (my_b_write(cache,(unsigned char*) start,(uint32_t) (pos-start)) || |
1285 |
my_b_write(cache,(unsigned char*) tmp_buff,2)) |
|
1864.3.18
by Brian Aker
REmove goto from session. |
1286 |
return true; |
1208.3.2
by brian
Update for Cursor renaming. |
1287 |
start=pos+1; |
1288 |
}
|
|
1289 |
}
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1290 |
if (my_b_write(cache,(unsigned char*) start,(uint32_t) (pos-start))) |
1864.3.18
by Brian Aker
REmove goto from session. |
1291 |
return true; |
1
by brian
clean slate |
1292 |
}
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1293 |
else if (my_b_write(cache,(unsigned char*) res->ptr(),used_length)) |
1864.3.18
by Brian Aker
REmove goto from session. |
1294 |
return true; |
1
by brian
clean slate |
1295 |
}
|
1296 |
if (fixed_row_size) |
|
1297 |
{ // Fill with space |
|
1298 |
if (item->max_length > used_length) |
|
1299 |
{
|
|
1208.3.2
by brian
Update for Cursor renaming. |
1300 |
/* QQ: Fix by adding a my_b_fill() function */
|
1301 |
if (!space_inited) |
|
1302 |
{
|
|
1303 |
space_inited=1; |
|
1304 |
memset(space, ' ', sizeof(space)); |
|
1305 |
}
|
|
1306 |
uint32_t length=item->max_length-used_length; |
|
1307 |
for (; length > sizeof(space) ; length-=sizeof(space)) |
|
1308 |
{
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1309 |
if (my_b_write(cache,(unsigned char*) space,sizeof(space))) |
1864.3.18
by Brian Aker
REmove goto from session. |
1310 |
return true; |
1208.3.2
by brian
Update for Cursor renaming. |
1311 |
}
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1312 |
if (my_b_write(cache,(unsigned char*) space,length)) |
1864.3.18
by Brian Aker
REmove goto from session. |
1313 |
return true; |
1
by brian
clean slate |
1314 |
}
|
1315 |
}
|
|
1316 |
if (res && enclosed) |
|
1317 |
{
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1318 |
if (my_b_write(cache, (unsigned char*) exchange->enclosed->ptr(), |
1
by brian
clean slate |
1319 |
exchange->enclosed->length())) |
1864.3.18
by Brian Aker
REmove goto from session. |
1320 |
return true; |
1
by brian
clean slate |
1321 |
}
|
1322 |
if (--items_left) |
|
1323 |
{
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1324 |
if (my_b_write(cache, (unsigned char*) exchange->field_term->ptr(), |
1
by brian
clean slate |
1325 |
field_term_length)) |
1864.3.18
by Brian Aker
REmove goto from session. |
1326 |
return true; |
1
by brian
clean slate |
1327 |
}
|
1328 |
}
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1329 |
if (my_b_write(cache,(unsigned char*) exchange->line_term->ptr(), |
1208.3.2
by brian
Update for Cursor renaming. |
1330 |
exchange->line_term->length())) |
1864.3.18
by Brian Aker
REmove goto from session. |
1331 |
{
|
1332 |
return true; |
|
1333 |
}
|
|
1334 |
||
1335 |
return false; |
|
1
by brian
clean slate |
1336 |
}
|
1337 |
||
1338 |
||
1339 |
/***************************************************************************
|
|
1340 |
** Dump of select to a binary file
|
|
1341 |
***************************************************************************/
|
|
1342 |
||
1343 |
||
1344 |
int
|
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
1345 |
select_dump::prepare(List<Item> &, Select_Lex_Unit *u) |
1
by brian
clean slate |
1346 |
{
|
1347 |
unit= u; |
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1348 |
return (int) ((file= create_file(session, path, exchange, cache)) < 0); |
1
by brian
clean slate |
1349 |
}
|
1350 |
||
1351 |
||
1352 |
bool select_dump::send_data(List<Item> &items) |
|
1353 |
{
|
|
1354 |
List_iterator_fast<Item> li(items); |
|
1355 |
char buff[MAX_FIELD_WIDTH]; |
|
1356 |
String tmp(buff,sizeof(buff),&my_charset_bin),*res; |
|
1357 |
tmp.length(0); |
|
1358 |
Item *item; |
|
1359 |
||
1360 |
if (unit->offset_limit_cnt) |
|
1361 |
{ // using limit offset,count |
|
1362 |
unit->offset_limit_cnt--; |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1363 |
return(0); |
1
by brian
clean slate |
1364 |
}
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1365 |
if (row_count++ > 1) |
1
by brian
clean slate |
1366 |
{
|
1367 |
my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0)); |
|
1813.2.12
by Monty Taylor
Made load_file work properly with throwing errors and opening files. |
1368 |
return 1; |
1
by brian
clean slate |
1369 |
}
|
1370 |
while ((item=li++)) |
|
1371 |
{
|
|
1372 |
res=item->str_result(&tmp); |
|
1373 |
if (!res) // If NULL |
|
1374 |
{
|
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1375 |
if (my_b_write(cache,(unsigned char*) "",1)) |
1813.2.12
by Monty Taylor
Made load_file work properly with throwing errors and opening files. |
1376 |
return 1; |
1
by brian
clean slate |
1377 |
}
|
1241.9.49
by Monty Taylor
Removed one more public IO_CACHE. |
1378 |
else if (my_b_write(cache,(unsigned char*) res->ptr(),res->length())) |
1
by brian
clean slate |
1379 |
{
|
1813.2.9
by Monty Taylor
Made data_home be fs::path natively. |
1380 |
my_error(ER_ERROR_ON_WRITE, MYF(0), path.file_string().c_str(), errno); |
1813.2.12
by Monty Taylor
Made load_file work properly with throwing errors and opening files. |
1381 |
return 1; |
1
by brian
clean slate |
1382 |
}
|
1383 |
}
|
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1384 |
return(0); |
1
by brian
clean slate |
1385 |
}
|
1386 |
||
1387 |
||
1388 |
select_subselect::select_subselect(Item_subselect *item_arg) |
|
1389 |
{
|
|
1390 |
item= item_arg; |
|
1391 |
}
|
|
1392 |
||
1393 |
||
1394 |
bool select_singlerow_subselect::send_data(List<Item> &items) |
|
1395 |
{
|
|
1396 |
Item_singlerow_subselect *it= (Item_singlerow_subselect *)item; |
|
1397 |
if (it->assigned()) |
|
1398 |
{
|
|
1399 |
my_message(ER_SUBQUERY_NO_1_ROW, ER(ER_SUBQUERY_NO_1_ROW), MYF(0)); |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1400 |
return(1); |
1
by brian
clean slate |
1401 |
}
|
1402 |
if (unit->offset_limit_cnt) |
|
1403 |
{ // Using limit offset,count |
|
1404 |
unit->offset_limit_cnt--; |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1405 |
return(0); |
1
by brian
clean slate |
1406 |
}
|
1407 |
List_iterator_fast<Item> li(items); |
|
1408 |
Item *val_item; |
|
482
by Brian Aker
Remove uint. |
1409 |
for (uint32_t i= 0; (val_item= li++); i++) |
1
by brian
clean slate |
1410 |
it->store(i, val_item); |
1411 |
it->assigned(1); |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1412 |
return(0); |
1
by brian
clean slate |
1413 |
}
|
1414 |
||
1415 |
||
1416 |
void select_max_min_finder_subselect::cleanup() |
|
1417 |
{
|
|
1418 |
cache= 0; |
|
1419 |
}
|
|
1420 |
||
1421 |
||
1422 |
bool select_max_min_finder_subselect::send_data(List<Item> &items) |
|
1423 |
{
|
|
1424 |
Item_maxmin_subselect *it= (Item_maxmin_subselect *)item; |
|
1425 |
List_iterator_fast<Item> li(items); |
|
1426 |
Item *val_item= li++; |
|
1427 |
it->register_value(); |
|
1428 |
if (it->assigned()) |
|
1429 |
{
|
|
1430 |
cache->store(val_item); |
|
1431 |
if ((this->*op)()) |
|
1432 |
it->store(0, cache); |
|
1433 |
}
|
|
1434 |
else
|
|
1435 |
{
|
|
1436 |
if (!cache) |
|
1437 |
{
|
|
1438 |
cache= Item_cache::get_cache(val_item); |
|
1439 |
switch (val_item->result_type()) |
|
1440 |
{
|
|
1441 |
case REAL_RESULT: |
|
1843.7.1
by Brian Aker
Convert vector to list (it will make deletion a bit faster). |
1442 |
op= &select_max_min_finder_subselect::cmp_real; |
1443 |
break; |
|
1
by brian
clean slate |
1444 |
case INT_RESULT: |
1843.7.1
by Brian Aker
Convert vector to list (it will make deletion a bit faster). |
1445 |
op= &select_max_min_finder_subselect::cmp_int; |
1446 |
break; |
|
1
by brian
clean slate |
1447 |
case STRING_RESULT: |
1843.7.1
by Brian Aker
Convert vector to list (it will make deletion a bit faster). |
1448 |
op= &select_max_min_finder_subselect::cmp_str; |
1449 |
break; |
|
1
by brian
clean slate |
1450 |
case DECIMAL_RESULT: |
1451 |
op= &select_max_min_finder_subselect::cmp_decimal; |
|
1452 |
break; |
|
1453 |
case ROW_RESULT: |
|
1454 |
// This case should never be choosen
|
|
1843.7.1
by Brian Aker
Convert vector to list (it will make deletion a bit faster). |
1455 |
assert(0); |
1456 |
op= 0; |
|
1
by brian
clean slate |
1457 |
}
|
1458 |
}
|
|
1459 |
cache->store(val_item); |
|
1460 |
it->store(0, cache); |
|
1461 |
}
|
|
1462 |
it->assigned(1); |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1463 |
return(0); |
1
by brian
clean slate |
1464 |
}
|
1465 |
||
1466 |
bool select_max_min_finder_subselect::cmp_real() |
|
1467 |
{
|
|
1468 |
Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); |
|
1469 |
double val1= cache->val_real(), val2= maxmin->val_real(); |
|
1470 |
if (fmax) |
|
1471 |
return (cache->null_value && !maxmin->null_value) || |
|
1472 |
(!cache->null_value && !maxmin->null_value && |
|
1473 |
val1 > val2); |
|
1474 |
return (maxmin->null_value && !cache->null_value) || |
|
1475 |
(!cache->null_value && !maxmin->null_value && |
|
1476 |
val1 < val2); |
|
1477 |
}
|
|
1478 |
||
1479 |
bool select_max_min_finder_subselect::cmp_int() |
|
1480 |
{
|
|
1481 |
Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); |
|
152
by Brian Aker
longlong replacement |
1482 |
int64_t val1= cache->val_int(), val2= maxmin->val_int(); |
1
by brian
clean slate |
1483 |
if (fmax) |
1484 |
return (cache->null_value && !maxmin->null_value) || |
|
1485 |
(!cache->null_value && !maxmin->null_value && |
|
1486 |
val1 > val2); |
|
1487 |
return (maxmin->null_value && !cache->null_value) || |
|
1488 |
(!cache->null_value && !maxmin->null_value && |
|
1489 |
val1 < val2); |
|
1490 |
}
|
|
1491 |
||
1492 |
bool select_max_min_finder_subselect::cmp_decimal() |
|
1493 |
{
|
|
1494 |
Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); |
|
1495 |
my_decimal cval, *cvalue= cache->val_decimal(&cval); |
|
1496 |
my_decimal mval, *mvalue= maxmin->val_decimal(&mval); |
|
1497 |
if (fmax) |
|
1498 |
return (cache->null_value && !maxmin->null_value) || |
|
1499 |
(!cache->null_value && !maxmin->null_value && |
|
1500 |
my_decimal_cmp(cvalue, mvalue) > 0) ; |
|
1501 |
return (maxmin->null_value && !cache->null_value) || |
|
1502 |
(!cache->null_value && !maxmin->null_value && |
|
1503 |
my_decimal_cmp(cvalue,mvalue) < 0); |
|
1504 |
}
|
|
1505 |
||
1506 |
bool select_max_min_finder_subselect::cmp_str() |
|
1507 |
{
|
|
1508 |
String *val1, *val2, buf1, buf2; |
|
1509 |
Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); |
|
1510 |
/*
|
|
1511 |
as far as both operand is Item_cache buf1 & buf2 will not be used,
|
|
1512 |
but added for safety
|
|
1513 |
*/
|
|
1514 |
val1= cache->val_str(&buf1); |
|
1515 |
val2= maxmin->val_str(&buf1); |
|
1516 |
if (fmax) |
|
1517 |
return (cache->null_value && !maxmin->null_value) || |
|
1518 |
(!cache->null_value && !maxmin->null_value && |
|
1519 |
sortcmp(val1, val2, cache->collation.collation) > 0) ; |
|
1520 |
return (maxmin->null_value && !cache->null_value) || |
|
1521 |
(!cache->null_value && !maxmin->null_value && |
|
1522 |
sortcmp(val1, val2, cache->collation.collation) < 0); |
|
1523 |
}
|
|
1524 |
||
779.1.27
by Monty Taylor
Got rid of __attribute__((unused)) and the like from the .cc files. |
1525 |
bool select_exists_subselect::send_data(List<Item> &) |
1
by brian
clean slate |
1526 |
{
|
1527 |
Item_exists_subselect *it= (Item_exists_subselect *)item; |
|
1528 |
if (unit->offset_limit_cnt) |
|
77.1.45
by Monty Taylor
Warning fixes. |
1529 |
{ // Using limit offset,count |
1
by brian
clean slate |
1530 |
unit->offset_limit_cnt--; |
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1531 |
return(0); |
1
by brian
clean slate |
1532 |
}
|
1533 |
it->value= 1; |
|
1534 |
it->assigned(1); |
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1535 |
return(0); |
1
by brian
clean slate |
1536 |
}
|
1537 |
||
406
by Brian Aker
Cleanup around Query_arena. |
1538 |
/*
|
1539 |
Don't free mem_root, as mem_root is freed in the end of dispatch_command
|
|
1540 |
(once for any command).
|
|
1541 |
*/
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1542 |
void Session::end_statement() |
1
by brian
clean slate |
1543 |
{
|
1544 |
/* Cleanup SQL processing state to reuse this statement in next query. */
|
|
1897.1.5
by Brian Aker
Move lex_end to be class member. |
1545 |
lex->end(); |
1643.6.1
by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin |
1546 |
query_cache_key= ""; // reset the cache key |
1643.6.16
by Djellel E. Difallah
Fixing memory leaks |
1547 |
resetResultsetMessage(); |
1
by brian
clean slate |
1548 |
}
|
1549 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1550 |
bool Session::copy_db_to(char **p_db, size_t *p_db_length) |
202.3.6
by Monty Taylor
First pass at gettexizing the error messages. |
1551 |
{
|
1220.1.9
by Brian Aker
Remove char *db from session, and replaces it with std::string. |
1552 |
if (db.empty()) |
202.3.6
by Monty Taylor
First pass at gettexizing the error messages. |
1553 |
{
|
1554 |
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); |
|
1555 |
return true; |
|
1556 |
}
|
|
1220.1.9
by Brian Aker
Remove char *db from session, and replaces it with std::string. |
1557 |
*p_db= strmake(db.c_str(), db.length()); |
1558 |
*p_db_length= db.length(); |
|
202.3.6
by Monty Taylor
First pass at gettexizing the error messages. |
1559 |
return false; |
1560 |
}
|
|
1561 |
||
1101.1.16
by Monty Taylor
Reverted 1103 |
1562 |
/****************************************************************************
|
1563 |
Tmp_Table_Param
|
|
1564 |
****************************************************************************/
|
|
1565 |
||
1566 |
void Tmp_Table_Param::init() |
|
1567 |
{
|
|
1568 |
field_count= sum_func_count= func_count= hidden_field_count= 0; |
|
1569 |
group_parts= group_length= group_null_parts= 0; |
|
1570 |
quick_group= 1; |
|
1571 |
table_charset= 0; |
|
1572 |
precomputed_group_by= 0; |
|
1573 |
}
|
|
1574 |
||
1575 |
void Tmp_Table_Param::cleanup(void) |
|
1576 |
{
|
|
1577 |
/* Fix for Intel compiler */
|
|
1578 |
if (copy_field) |
|
1579 |
{
|
|
1580 |
delete [] copy_field; |
|
1581 |
save_copy_field= copy_field= 0; |
|
1582 |
}
|
|
1583 |
}
|
|
1584 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1585 |
void Session::send_kill_message() const |
202.3.6
by Monty Taylor
First pass at gettexizing the error messages. |
1586 |
{
|
1587 |
int err= killed_errno(); |
|
1588 |
if (err) |
|
1589 |
my_message(err, ER(err), MYF(0)); |
|
1590 |
}
|
|
1
by brian
clean slate |
1591 |
|
520.1.21
by Brian Aker
THD -> Session rename |
1592 |
void Session::set_status_var_init() |
1
by brian
clean slate |
1593 |
{
|
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
1594 |
memset(&status_var, 0, sizeof(status_var)); |
1
by brian
clean slate |
1595 |
}
|
1596 |
||
1597 |
||
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
1598 |
bool Session::set_db(const std::string &new_db) |
656.1.22
by Monty Taylor
Removed my_malloc related stuff from log_event and session. |
1599 |
{
|
1273
by Brian Aker
Revert db patch. |
1600 |
/* Do not reallocate memory if current chunk is big enough. */
|
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
1601 |
if (new_db.length()) |
1273
by Brian Aker
Revert db patch. |
1602 |
db= new_db; |
1603 |
else
|
|
1604 |
db.clear(); |
|
1220.1.9
by Brian Aker
Remove char *db from session, and replaces it with std::string. |
1605 |
|
1606 |
return false; |
|
656.1.22
by Monty Taylor
Removed my_malloc related stuff from log_event and session. |
1607 |
}
|
1608 |
||
1273
by Brian Aker
Revert db patch. |
1609 |
|
1
by brian
clean slate |
1610 |
/**
|
1611 |
Mark transaction to rollback and mark error as fatal to a sub-statement.
|
|
1612 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1613 |
@param session Thread handle
|
51.1.50
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE |
1614 |
@param all true <=> rollback main transaction.
|
1
by brian
clean slate |
1615 |
*/
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1616 |
void mark_transaction_to_rollback(Session *session, bool all) |
1
by brian
clean slate |
1617 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1618 |
if (session) |
1
by brian
clean slate |
1619 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1620 |
session->is_fatal_sub_stmt_error= true; |
1621 |
session->transaction_rollback_request= all; |
|
1
by brian
clean slate |
1622 |
}
|
1623 |
}
|
|
1624 |
||
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
1625 |
void Session::disconnect(uint32_t errcode, bool should_lock) |
575.4.7
by Monty Taylor
More header cleanup. |
1626 |
{
|
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
1627 |
/* Allow any plugins to cleanup their session variables */
|
1628 |
plugin_sessionvar_cleanup(this); |
|
1629 |
||
1630 |
/* If necessary, log any aborted or unauthorized connections */
|
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
1631 |
if (getKilled() || client->wasAborted()) |
1537.2.1
by Joe Daly
add statistics_variables.h |
1632 |
{
|
1689.5.1
by Joseph Daly
remove increment calls |
1633 |
status_var.aborted_threads++; |
1537.2.1
by Joe Daly
add statistics_variables.h |
1634 |
}
|
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
1635 |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
1636 |
if (client->wasAborted()) |
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
1637 |
{
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
1638 |
if (not getKilled() && variables.log_warnings > 1) |
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
1639 |
{
|
1273.11.1
by Dennis Schoen
rename class |
1640 |
SecurityContext *sctx= &security_ctx; |
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
1641 |
|
1642 |
errmsg_printf(ERRMSG_LVL_WARN, ER(ER_NEW_ABORTING_CONNECTION) |
|
1643 |
, thread_id |
|
1220.1.9
by Brian Aker
Remove char *db from session, and replaces it with std::string. |
1644 |
, (db.empty() ? "unconnected" : db.c_str()) |
1273.11.2
by Dennis Schoen
make data members private |
1645 |
, sctx->getUser().empty() == false ? sctx->getUser().c_str() : "unauthenticated" |
1646 |
, sctx->getIp().c_str() |
|
934.2.6
by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h |
1647 |
, (main_da.is_error() ? main_da.message() : ER(ER_UNKNOWN_ERROR))); |
1648 |
}
|
|
1649 |
}
|
|
1650 |
||
1651 |
/* Close out our connection to the client */
|
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1652 |
if (should_lock) |
1932.3.4
by Brian Aker
Move counter lock so that ownership is held by session_list. |
1653 |
session::Cache::singleton().mutex().lock(); |
1910.2.8
by Brian Aker
Enapsulate Kill. |
1654 |
|
1655 |
setKilled(Session::KILL_CONNECTION); |
|
1656 |
||
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
1657 |
if (client->isConnected()) |
575.4.7
by Monty Taylor
More header cleanup. |
1658 |
{
|
1659 |
if (errcode) |
|
971.3.12
by Eric Day
Started abstracting Protocol, removed init_connect, init_file. |
1660 |
{
|
1661 |
/*my_error(errcode, ER(errcode));*/
|
|
971.6.11
by Eric Day
Removed purecov messages. |
1662 |
client->sendError(errcode, ER(errcode)); |
971.3.12
by Eric Day
Started abstracting Protocol, removed init_connect, init_file. |
1663 |
}
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
1664 |
client->close(); |
575.4.7
by Monty Taylor
More header cleanup. |
1665 |
}
|
1910.2.8
by Brian Aker
Enapsulate Kill. |
1666 |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1667 |
if (should_lock) |
1910.2.8
by Brian Aker
Enapsulate Kill. |
1668 |
{
|
1932.3.4
by Brian Aker
Move counter lock so that ownership is held by session_list. |
1669 |
session::Cache::singleton().mutex().unlock(); |
1910.2.8
by Brian Aker
Enapsulate Kill. |
1670 |
}
|
575.4.7
by Monty Taylor
More header cleanup. |
1671 |
}
|
735
by Brian Aker
Refactor session. |
1672 |
|
1673 |
void Session::reset_for_next_command() |
|
1674 |
{
|
|
1675 |
free_list= 0; |
|
1676 |
select_number= 1; |
|
1677 |
/*
|
|
1678 |
Those two lines below are theoretically unneeded as
|
|
1679 |
Session::cleanup_after_query() should take care of this already.
|
|
1680 |
*/
|
|
1681 |
auto_inc_intervals_in_cur_stmt_for_binlog.empty(); |
|
1682 |
||
1055.2.17
by Jay Pipes
More style cleanups in Session |
1683 |
is_fatal_error= false; |
735
by Brian Aker
Refactor session. |
1684 |
server_status&= ~ (SERVER_MORE_RESULTS_EXISTS | |
1685 |
SERVER_QUERY_NO_INDEX_USED | |
|
1686 |
SERVER_QUERY_NO_GOOD_INDEX_USED); |
|
1687 |
||
1688 |
clear_error(); |
|
1689 |
main_da.reset_diagnostics_area(); |
|
1690 |
total_warn_count=0; // Warnings for this query |
|
1691 |
sent_row_count= examined_row_count= 0; |
|
1692 |
}
|
|
793
by Brian Aker
Pass through on refactoring functions to clases. |
1693 |
|
1694 |
/*
|
|
1695 |
Close all temporary tables created by 'CREATE TEMPORARY TABLE' for thread
|
|
1696 |
*/
|
|
1697 |
||
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1698 |
void Open_tables_state::close_temporary_tables() |
793
by Brian Aker
Pass through on refactoring functions to clases. |
1699 |
{
|
1700 |
Table *table; |
|
798.2.20
by Brian Aker
More cleanup of binlog.isopen |
1701 |
Table *tmp_next; |
793
by Brian Aker
Pass through on refactoring functions to clases. |
1702 |
|
1395.1.11
by Brian Aker
Rename of close_temporary to nukeTable() so that my regex will stop looking |
1703 |
if (not temporary_tables) |
793
by Brian Aker
Pass through on refactoring functions to clases. |
1704 |
return; |
1705 |
||
798.2.20
by Brian Aker
More cleanup of binlog.isopen |
1706 |
for (table= temporary_tables; table; table= tmp_next) |
1707 |
{
|
|
1608
by Brian Aker
This encapsulates prev/next. |
1708 |
tmp_next= table->getNext(); |
1395.1.11
by Brian Aker
Rename of close_temporary to nukeTable() so that my regex will stop looking |
1709 |
nukeTable(table); |
798.2.20
by Brian Aker
More cleanup of binlog.isopen |
1710 |
}
|
1046.1.6
by Brian Aker
Formatting/style cleanup. |
1711 |
temporary_tables= NULL; |
793
by Brian Aker
Pass through on refactoring functions to clases. |
1712 |
}
|
855
by Brian Aker
Refactor reset of status. |
1713 |
|
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1714 |
/*
|
1715 |
unlink from session->temporary tables and close temporary table
|
|
1716 |
*/
|
|
1717 |
||
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1718 |
void Open_tables_state::close_temporary_table(Table *table) |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1719 |
{
|
1608
by Brian Aker
This encapsulates prev/next. |
1720 |
if (table->getPrev()) |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1721 |
{
|
1608
by Brian Aker
This encapsulates prev/next. |
1722 |
table->getPrev()->setNext(table->getNext()); |
1723 |
if (table->getPrev()->getNext()) |
|
1724 |
{
|
|
1725 |
table->getNext()->setPrev(table->getPrev()); |
|
1726 |
}
|
|
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1727 |
}
|
1728 |
else
|
|
1729 |
{
|
|
1730 |
/* removing the item from the list */
|
|
1731 |
assert(table == temporary_tables); |
|
1732 |
/*
|
|
1733 |
slave must reset its temporary list pointer to zero to exclude
|
|
1734 |
passing non-zero value to end_slave via rli->save_temporary_tables
|
|
1735 |
when no temp tables opened, see an invariant below.
|
|
1736 |
*/
|
|
1608
by Brian Aker
This encapsulates prev/next. |
1737 |
temporary_tables= table->getNext(); |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1738 |
if (temporary_tables) |
1608
by Brian Aker
This encapsulates prev/next. |
1739 |
{
|
1740 |
table->getNext()->setPrev(NULL); |
|
1741 |
}
|
|
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1742 |
}
|
1395.1.11
by Brian Aker
Rename of close_temporary to nukeTable() so that my regex will stop looking |
1743 |
nukeTable(table); |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1744 |
}
|
1745 |
||
1746 |
/*
|
|
1395.1.11
by Brian Aker
Rename of close_temporary to nukeTable() so that my regex will stop looking |
1747 |
Close and drop a temporary table
|
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1748 |
|
1749 |
NOTE
|
|
1750 |
This dosn't unlink table from session->temporary
|
|
1751 |
If this is needed, use close_temporary_table()
|
|
1752 |
*/
|
|
1753 |
||
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1754 |
void Open_tables_state::nukeTable(Table *table) |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1755 |
{
|
1532.1.15
by Brian Aker
Partial encapsulation of TableShare from Table. |
1756 |
plugin::StorageEngine *table_type= table->getShare()->db_type(); |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1757 |
|
1109.1.4
by Brian Aker
More Table refactor |
1758 |
table->free_io_cache(); |
1672.3.2
by Brian Aker
Tiny little cleanup around Table. |
1759 |
table->delete_table(); |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1760 |
|
1532.1.15
by Brian Aker
Partial encapsulation of TableShare from Table. |
1761 |
TableIdentifier identifier(table->getShare()->getSchemaName(), table->getShare()->getTableName(), table->getShare()->getPath()); |
1395.1.8
by Brian Aker
Cleanup usage of TI so that the NULL ones no longer exist. |
1762 |
rm_temporary_table(table_type, identifier); |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1763 |
|
1532.1.15
by Brian Aker
Partial encapsulation of TableShare from Table. |
1764 |
delete table->getMutableShare(); |
1237.6.12
by Brian Aker
Adding patch for engine methods for definition files. |
1765 |
|
1216.1.1
by Brian Aker
Move print_error up to Engine. |
1766 |
/* This makes me sad, but we're allocating it via malloc */
|
1669.2.4
by Brian Aker
Fix temp tables to use new over malloc. |
1767 |
delete table; |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1768 |
}
|
855
by Brian Aker
Refactor reset of status. |
1769 |
|
1770 |
/** Clear most status variables. */
|
|
1771 |
extern time_t flush_status_time; |
|
1772 |
||
1773 |
void Session::refresh_status() |
|
1774 |
{
|
|
1775 |
/* Reset thread's status variables */
|
|
1776 |
memset(&status_var, 0, sizeof(status_var)); |
|
1777 |
||
1778 |
flush_status_time= time((time_t*) 0); |
|
1537.2.1
by Joe Daly
add statistics_variables.h |
1779 |
current_global_counters.max_used_connections= 1; /* We set it to one, because we know we exist */ |
1726.3.3
by LinuxJedi
Add a proper connections counter. |
1780 |
current_global_counters.connections= 0; |
855
by Brian Aker
Refactor reset of status. |
1781 |
}
|
995
by Brian Aker
Refactor get_variable to session |
1782 |
|
1783 |
user_var_entry *Session::getVariable(LEX_STRING &name, bool create_if_not_exists) |
|
1784 |
{
|
|
1836.4.1
by Brian Aker
Adding in more test case for events (though these do not really have the |
1785 |
return getVariable(std::string(name.str, name.length), create_if_not_exists); |
1786 |
}
|
|
1787 |
||
1788 |
user_var_entry *Session::getVariable(const std::string &name, bool create_if_not_exists) |
|
1789 |
{
|
|
1790 |
UserVarsRange ppp= user_vars.equal_range(name); |
|
995
by Brian Aker
Refactor get_variable to session |
1791 |
|
1689.3.4
by Brian Aker
Remove the hash in session, for a boost based one. |
1792 |
for (UserVars::iterator iter= ppp.first; |
1859.3.1
by Brian Aker
Slight refactor of the uservar class. |
1793 |
iter != ppp.second; ++iter) |
1689.3.4
by Brian Aker
Remove the hash in session, for a boost based one. |
1794 |
{
|
1859.3.1
by Brian Aker
Slight refactor of the uservar class. |
1795 |
return (*iter).second; |
1689.3.4
by Brian Aker
Remove the hash in session, for a boost based one. |
1796 |
}
|
995
by Brian Aker
Refactor get_variable to session |
1797 |
|
1859.3.1
by Brian Aker
Slight refactor of the uservar class. |
1798 |
if (not create_if_not_exists) |
1799 |
return NULL; |
|
1800 |
||
1801 |
user_var_entry *entry= NULL; |
|
1802 |
entry= new (nothrow) user_var_entry(name.c_str(), query_id); |
|
1803 |
||
1804 |
if (entry == NULL) |
|
1805 |
return NULL; |
|
1806 |
||
1807 |
std::pair<UserVars::iterator, bool> returnable= user_vars.insert(make_pair(name, entry)); |
|
1808 |
||
1809 |
if (not returnable.second) |
|
995
by Brian Aker
Refactor get_variable to session |
1810 |
{
|
1859.3.1
by Brian Aker
Slight refactor of the uservar class. |
1811 |
delete entry; |
995
by Brian Aker
Refactor get_variable to session |
1812 |
}
|
1813 |
||
1814 |
return entry; |
|
1815 |
}
|
|
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1816 |
|
1836.4.1
by Brian Aker
Adding in more test case for events (though these do not really have the |
1817 |
void Session::setVariable(const std::string &name, const std::string &value) |
1818 |
{
|
|
1819 |
user_var_entry *updateable_var= getVariable(name.c_str(), true); |
|
1820 |
||
1821 |
updateable_var->update_hash(false, |
|
1822 |
(void*)value.c_str(), |
|
1823 |
static_cast<uint32_t>(value.length()), STRING_RESULT, |
|
1824 |
&my_charset_bin, |
|
1825 |
DERIVATION_IMPLICIT, false); |
|
1826 |
}
|
|
1827 |
||
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1828 |
void Open_tables_state::mark_temp_tables_as_free_for_reuse() |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1829 |
{
|
1608
by Brian Aker
This encapsulates prev/next. |
1830 |
for (Table *table= temporary_tables ; table ; table= table->getNext()) |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1831 |
{
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1832 |
if (table->query_id == getQueryId()) |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1833 |
{
|
1834 |
table->query_id= 0; |
|
1208.3.2
by brian
Update for Cursor renaming. |
1835 |
table->cursor->ha_reset(); |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1836 |
}
|
1837 |
}
|
|
1838 |
}
|
|
1839 |
||
1840 |
void Session::mark_used_tables_as_free_for_reuse(Table *table) |
|
1841 |
{
|
|
1608
by Brian Aker
This encapsulates prev/next. |
1842 |
for (; table ; table= table->getNext()) |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1843 |
{
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1844 |
if (table->query_id == getQueryId()) |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1845 |
{
|
1846 |
table->query_id= 0; |
|
1208.3.2
by brian
Update for Cursor renaming. |
1847 |
table->cursor->ha_reset(); |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1848 |
}
|
1849 |
}
|
|
1850 |
}
|
|
1851 |
||
1852 |
/*
|
|
1055.2.24
by Jay Pipes
Merge with trunk and resolve conflicts. |
1853 |
Unlocks tables and frees derived tables.
|
1854 |
Put all normal tables used by thread in free list.
|
|
1855 |
||
1856 |
It will only close/mark as free for reuse tables opened by this
|
|
1857 |
substatement, it will also check if we are closing tables after
|
|
1858 |
execution of complete query (i.e. we are on upper level) and will
|
|
1859 |
leave prelocked mode if needed.
|
|
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1860 |
*/
|
1861 |
void Session::close_thread_tables() |
|
1862 |
{
|
|
1923.1.3
by Brian Aker
Encapsulate derived tables |
1863 |
clearDerivedTables(); |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1864 |
|
1865 |
/*
|
|
1866 |
Mark all temporary tables used by this statement as free for reuse.
|
|
1867 |
*/
|
|
1868 |
mark_temp_tables_as_free_for_reuse(); |
|
1869 |
/*
|
|
1870 |
Let us commit transaction for statement. Since in 5.0 we only have
|
|
1871 |
one statement transaction and don't allow several nested statement
|
|
1872 |
transactions this call will do nothing if we are inside of stored
|
|
1873 |
function or trigger (i.e. statement transaction is already active and
|
|
1874 |
does not belong to statement for which we do close_thread_tables()).
|
|
1875 |
TODO: This should be fixed in later releases.
|
|
1876 |
*/
|
|
1877 |
{
|
|
1273.1.2
by Jay Pipes
This patch does not change any algorithms or code paths, |
1878 |
TransactionServices &transaction_services= TransactionServices::singleton(); |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1879 |
main_da.can_overwrite_status= true; |
1405.3.5
by Jay Pipes
TransactionServices method names now meet code style guidelines. |
1880 |
transaction_services.autocommitOrRollback(this, is_error()); |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1881 |
main_da.can_overwrite_status= false; |
1882 |
transaction.stmt.reset(); |
|
1883 |
}
|
|
1884 |
||
1885 |
if (lock) |
|
1886 |
{
|
|
1887 |
/*
|
|
1888 |
For RBR we flush the pending event just before we unlock all the
|
|
1889 |
tables. This means that we are at the end of a topmost
|
|
1890 |
statement, so we ensure that the STMT_END_F flag is set on the
|
|
1891 |
pending event. For statements that are *inside* stored
|
|
1892 |
functions, the pending event will not be flushed: that will be
|
|
1893 |
handled either before writing a query log event (inside
|
|
1894 |
binlog_query()) or when preparing a pending event.
|
|
1895 |
*/
|
|
1910.2.7
by Brian Aker
Rename lock methods to be style + well make sense. |
1896 |
unlockTables(lock); |
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1897 |
lock= 0; |
1898 |
}
|
|
1899 |
/*
|
|
1900 |
Note that we need to hold LOCK_open while changing the
|
|
1901 |
open_tables list. Another thread may work on it.
|
|
1887.2.5
by Brian Aker
OSX found a reference to a function that was no longer declared. |
1902 |
(See: table::Cache::singleton().removeTable(), mysql_wait_completed_table())
|
1039.1.16
by Brian Aker
A lot of little cleanups (most based off lcov) |
1903 |
Closing a MERGE child before the parent would be fatal if the
|
1904 |
other thread tries to abort the MERGE lock in between.
|
|
1905 |
*/
|
|
1906 |
if (open_tables) |
|
1907 |
close_open_tables(); |
|
1908 |
}
|
|
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1909 |
|
1910 |
void Session::close_tables_for_reopen(TableList **tables) |
|
1911 |
{
|
|
1912 |
/*
|
|
1913 |
If table list consists only from tables from prelocking set, table list
|
|
1914 |
for new attempt should be empty, so we have to update list's root pointer.
|
|
1915 |
*/
|
|
1916 |
if (lex->first_not_own_table() == *tables) |
|
1917 |
*tables= 0; |
|
1918 |
lex->chop_off_not_own_tables(); |
|
1919 |
for (TableList *tmp= *tables; tmp; tmp= tmp->next_global) |
|
1920 |
tmp->table= 0; |
|
1921 |
close_thread_tables(); |
|
1922 |
}
|
|
1923 |
||
1109.1.3
by Brian Aker
Move names around a bit (to align similar methods) |
1924 |
bool Session::openTablesLock(TableList *tables) |
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1925 |
{
|
1926 |
uint32_t counter; |
|
1927 |
bool need_reopen; |
|
1928 |
||
1929 |
for ( ; ; ) |
|
1930 |
{
|
|
1109.1.2
by Brian Aker
More from the table patch |
1931 |
if (open_tables_from_list(&tables, &counter)) |
1932 |
return true; |
|
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1933 |
|
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
1934 |
if (not lock_tables(tables, counter, &need_reopen)) |
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1935 |
break; |
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
1936 |
if (not need_reopen) |
1109.1.2
by Brian Aker
More from the table patch |
1937 |
return true; |
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1938 |
close_tables_for_reopen(&tables); |
1939 |
}
|
|
1940 |
if ((mysql_handle_derived(lex, &mysql_derived_prepare) || |
|
1812.5.4
by Brian Aker
Next update in stdint |
1941 |
(
|
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1942 |
mysql_handle_derived(lex, &mysql_derived_filling)))) |
971.6.11
by Eric Day
Removed purecov messages. |
1943 |
return true; |
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1944 |
|
1109.1.2
by Brian Aker
More from the table patch |
1945 |
return false; |
1054.1.9
by Brian Aker
This is a large number of refactors against the Session class for its |
1946 |
}
|
1947 |
||
1608.2.1
by Brian Aker
Modified to table identifier to fix temporary table creation loss of file. |
1948 |
/*
|
1949 |
@note "best_effort" is used in cases were if a failure occurred on this
|
|
1950 |
operation it would not be surprising because we are only removing because there
|
|
1951 |
might be an issue (lame engines).
|
|
1952 |
*/
|
|
1953 |
||
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1954 |
bool Open_tables_state::rm_temporary_table(TableIdentifier &identifier, bool best_effort) |
1223.4.8
by Brian Aker
More table identifier love :) |
1955 |
{
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1956 |
if (plugin::StorageEngine::dropTable(*static_cast<Session *>(this), identifier)) |
1223.4.8
by Brian Aker
More table identifier love :) |
1957 |
{
|
1608.2.1
by Brian Aker
Modified to table identifier to fix temporary table creation loss of file. |
1958 |
if (not best_effort) |
1959 |
{
|
|
1960 |
errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"), |
|
1961 |
identifier.getSQLPath().c_str(), errno); |
|
1962 |
}
|
|
1320.1.9
by Brian Aker
Removing special case dropTable() |
1963 |
|
1964 |
return true; |
|
1223.4.8
by Brian Aker
More table identifier love :) |
1965 |
}
|
1320.1.9
by Brian Aker
Removing special case dropTable() |
1966 |
|
1967 |
return false; |
|
1223.4.8
by Brian Aker
More table identifier love :) |
1968 |
}
|
1969 |
||
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1970 |
bool Open_tables_state::rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier) |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1971 |
{
|
1972 |
assert(base); |
|
1973 |
||
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1974 |
if (plugin::StorageEngine::dropTable(*static_cast<Session *>(this), *base, identifier)) |
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
1975 |
{
|
1976 |
errmsg_printf(ERRMSG_LVL_WARN, _("Could not remove temporary table: '%s', error: %d"), |
|
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
1977 |
identifier.getSQLPath().c_str(), errno); |
1978 |
||
1979 |
return true; |
|
1980 |
}
|
|
1981 |
||
1982 |
return false; |
|
1983 |
}
|
|
1984 |
||
1985 |
/**
|
|
1986 |
@note this will be removed, I am looking through Hudson to see if it is finding
|
|
1987 |
any tables that are missed during cleanup.
|
|
1988 |
*/
|
|
1922.1.1
by Brian Aker
Move temp tables down to open_table class. (first pass) |
1989 |
void Open_tables_state::dumpTemporaryTableNames(const char *foo) |
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
1990 |
{
|
1991 |
Table *table; |
|
1992 |
||
1993 |
if (not temporary_tables) |
|
1994 |
return; |
|
1995 |
||
1996 |
cerr << "Begin Run: " << foo << "\n"; |
|
1608
by Brian Aker
This encapsulates prev/next. |
1997 |
for (table= temporary_tables; table; table= table->getNext()) |
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
1998 |
{
|
1999 |
bool have_proto= false; |
|
2000 |
||
1532.1.15
by Brian Aker
Partial encapsulation of TableShare from Table. |
2001 |
message::Table *proto= table->getShare()->getTableProto(); |
2002 |
if (table->getShare()->getTableProto()) |
|
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
2003 |
have_proto= true; |
2004 |
||
2005 |
const char *answer= have_proto ? "true" : "false"; |
|
2006 |
||
2007 |
if (have_proto) |
|
2008 |
{
|
|
1532.1.15
by Brian Aker
Partial encapsulation of TableShare from Table. |
2009 |
cerr << "\tTable Name " << table->getShare()->getSchemaName() << "." << table->getShare()->getTableName() << " : " << answer << "\n"; |
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
2010 |
cerr << "\t\t Proto " << proto->schema() << " " << proto->name() << "\n"; |
2011 |
}
|
|
2012 |
else
|
|
1532.1.15
by Brian Aker
Partial encapsulation of TableShare from Table. |
2013 |
cerr << "\tTabl;e Name " << table->getShare()->getSchemaName() << "." << table->getShare()->getTableName() << " : " << answer << "\n"; |
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
2014 |
}
|
1109.1.1
by Brian Aker
Applying refactor of tmp table bits back to session. (this all needs to be |
2015 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2016 |
|
1923.1.4
by Brian Aker
Encapsulate up the cache we use in Session for tracking table proto for temp |
2017 |
bool Session::TableMessages::storeTableMessage(const TableIdentifier &identifier, message::Table &table_message) |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2018 |
{
|
2019 |
table_message_cache.insert(make_pair(identifier.getPath(), table_message)); |
|
2020 |
||
2021 |
return true; |
|
2022 |
}
|
|
2023 |
||
1923.1.4
by Brian Aker
Encapsulate up the cache we use in Session for tracking table proto for temp |
2024 |
bool Session::TableMessages::removeTableMessage(const TableIdentifier &identifier) |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2025 |
{
|
2026 |
TableMessageCache::iterator iter; |
|
2027 |
||
2028 |
iter= table_message_cache.find(identifier.getPath()); |
|
2029 |
||
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
2030 |
if (iter == table_message_cache.end()) |
2031 |
return false; |
|
2032 |
||
2033 |
table_message_cache.erase(iter); |
|
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2034 |
|
2035 |
return true; |
|
2036 |
}
|
|
2037 |
||
1923.1.4
by Brian Aker
Encapsulate up the cache we use in Session for tracking table proto for temp |
2038 |
bool Session::TableMessages::getTableMessage(const TableIdentifier &identifier, message::Table &table_message) |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2039 |
{
|
2040 |
TableMessageCache::iterator iter; |
|
2041 |
||
2042 |
iter= table_message_cache.find(identifier.getPath()); |
|
2043 |
||
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
2044 |
if (iter == table_message_cache.end()) |
2045 |
return false; |
|
2046 |
||
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2047 |
table_message.CopyFrom(((*iter).second)); |
2048 |
||
2049 |
return true; |
|
2050 |
}
|
|
2051 |
||
1923.1.4
by Brian Aker
Encapsulate up the cache we use in Session for tracking table proto for temp |
2052 |
bool Session::TableMessages::doesTableMessageExist(const TableIdentifier &identifier) |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2053 |
{
|
2054 |
TableMessageCache::iterator iter; |
|
2055 |
||
2056 |
iter= table_message_cache.find(identifier.getPath()); |
|
2057 |
||
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
2058 |
if (iter == table_message_cache.end()) |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2059 |
{
|
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
2060 |
return false; |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2061 |
}
|
2062 |
||
1372.1.4
by Brian Aker
Update to remove cache in enginges for per session (which also means... no |
2063 |
return true; |
1358.1.2
by Brian Aker
Long pass through the system to use more of TableIdentifiers. |
2064 |
}
|
2065 |
||
1923.1.4
by Brian Aker
Encapsulate up the cache we use in Session for tracking table proto for temp |
2066 |
bool Session::TableMessages::renameTableMessage(const TableIdentifier &from, const TableIdentifier &to) |
1390
by Brian Aker
Update interface to use Identifiers directly. |
2067 |
{
|
2068 |
TableMessageCache::iterator iter; |
|
2069 |
||
2070 |
table_message_cache[to.getPath()]= table_message_cache[from.getPath()]; |
|
2071 |
||
1395.1.1
by Brian Aker
Fixes for alter table to make sure that the proto on disk is valid. |
2072 |
iter= table_message_cache.find(to.getPath()); |
2073 |
||
2074 |
if (iter == table_message_cache.end()) |
|
2075 |
{
|
|
2076 |
return false; |
|
2077 |
}
|
|
2078 |
||
1395.1.12
by Brian Aker
Fixes failure related to Heap's hack on deletion. Also cleans up error |
2079 |
(*iter).second.set_schema(to.getSchemaName()); |
2080 |
(*iter).second.set_name(to.getTableName()); |
|
1390
by Brian Aker
Update interface to use Identifiers directly. |
2081 |
|
2082 |
return true; |
|
2083 |
}
|
|
2084 |
||
1843.8.5
by Brian Aker
Added concurrent type. |
2085 |
table::Instance *Session::getInstanceTable() |
1618
by Brian Aker
This is a rollup set of patches for modifications to TableIdentifier to have |
2086 |
{
|
1843.8.5
by Brian Aker
Added concurrent type. |
2087 |
temporary_shares.push_back(new table::Instance()); // This will not go into the tableshare cache, so no key is used. |
1532.1.1
by Brian Aker
Merge of change to flip table instance to be share instance |
2088 |
|
1843.8.4
by Brian Aker
Committing refactor of table out (this is part of the concurrency work). |
2089 |
table::Instance *tmp_share= temporary_shares.back(); |
1532.1.1
by Brian Aker
Merge of change to flip table instance to be share instance |
2090 |
|
2091 |
assert(tmp_share); |
|
2092 |
||
2093 |
return tmp_share; |
|
2094 |
}
|
|
2095 |
||
1878.5.1
by Brian Aker
Update instance for handling construction of virtual_tmp |
2096 |
|
2097 |
/**
|
|
2098 |
Create a reduced Table object with properly set up Field list from a
|
|
2099 |
list of field definitions.
|
|
2100 |
||
2101 |
The created table doesn't have a table Cursor associated with
|
|
2102 |
it, has no keys, no group/distinct, no copy_funcs array.
|
|
2103 |
The sole purpose of this Table object is to use the power of Field
|
|
2104 |
class to read/write data to/from table->getInsertRecord(). Then one can store
|
|
2105 |
the record in any container (RB tree, hash, etc).
|
|
2106 |
The table is created in Session mem_root, so are the table's fields.
|
|
2107 |
Consequently, if you don't BLOB fields, you don't need to free it.
|
|
2108 |
||
2109 |
@param session connection handle
|
|
2110 |
@param field_list list of column definitions
|
|
2111 |
||
2112 |
@return
|
|
2113 |
0 if out of memory, Table object in case of success
|
|
2114 |
*/
|
|
2115 |
table::Instance *Session::getInstanceTable(List<CreateField> &field_list) |
|
2116 |
{
|
|
2117 |
temporary_shares.push_back(new table::Instance(this, field_list)); // This will not go into the tableshare cache, so no key is used. |
|
2118 |
||
2119 |
table::Instance *tmp_share= temporary_shares.back(); |
|
2120 |
||
2121 |
assert(tmp_share); |
|
2122 |
||
2123 |
return tmp_share; |
|
2124 |
}
|
|
2125 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2126 |
} /* namespace drizzled */ |