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