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