~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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.
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
520.6.7 by Monty Taylor
Moved a bunch of crap out of common_includes.
21
2187.2.1 by Brian Aker
Additional fixes in headers.
22
#include <algorithm>
23
#include <bitset>
24
#include <boost/make_shared.hpp>
2239.1.10 by Olaf van der Spek
Refactor includes
25
#include <boost/scoped_ptr.hpp>
2187.2.1 by Brian Aker
Additional fixes in headers.
26
#include <boost/thread/condition_variable.hpp>
27
#include <boost/thread/mutex.hpp>
28
#include <boost/thread/shared_mutex.hpp>
29
#include <boost/thread/thread.hpp>
30
#include <map>
31
#include <netdb.h>
32
#include <string>
33
#include <sys/resource.h>
34
#include <sys/time.h>
35
2281.5.1 by Muhammad Umair
Merged charset declarations of global_charset_info.h and charset_info.h into charset.h header file.
36
#include <drizzled/charset.h>
2239.1.6 by Olaf van der Spek
Refactor includes
37
#include <drizzled/base.h>
2227.4.3 by Olaf van der Spek
Remove unnecessary statement.h include
38
#include <drizzled/error.h>
2263.3.11 by Olaf van der Spek
Open Tables
39
#include <drizzled/lock.h>
2154.2.21 by Brian Aker
sort includes
40
#include <drizzled/pthread_globals.h>
41
#include <drizzled/sql_error.h>
42
#include <drizzled/sql_locale.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
43
#include <drizzled/visibility.h>
2192.5.1 by Olaf van der Spek
Use find_ptr
44
#include <drizzled/util/find_ptr.h>
2241.2.14 by Olaf van der Spek
Refactor
45
#include <drizzled/util/string.h>
2198.1.2 by Olaf van der Spek
Refactor includes
46
#include <drizzled/type/time.h>
47
2227.4.11 by Olaf van der Spek
Refactor Session
48
namespace drizzled {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
49
2241.3.3 by Olaf van der Spek
Refactor Session::transaction (partial)
50
extern uint32_t server_id;
2290.1.1 by Joseph Daly
Add server uuid
51
extern std::string server_uuid;
1 by brian
clean slate
52
53
#define TC_HEURISTIC_RECOVER_COMMIT   1
54
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
482 by Brian Aker
Remove uint.
55
extern uint32_t tc_heuristic_recover;
1 by brian
clean slate
56
2119.4.2 by Monty Taylor
Fixed a sun studio compile issue.
57
extern DRIZZLED_API struct drizzle_system_variables global_system_variables;
520.6.7 by Monty Taylor
Moved a bunch of crap out of common_includes.
58
1100.3.29 by Padraig O'Sullivan
Removed the Statement class. Copied any members it had that were needed by
59
/**
60
 * Represents a client connection to the database server.
61
 *
62
 * Contains the client/server protocol object, the current statement
63
 * being executed, local-to-session variables and status counters, and
64
 * a host of other information.
65
 *
66
 * @todo
67
 *
1100.3.34 by Padraig O'Sullivan
Various updates after great code review from Jay. Thanks Jay!
68
 * The Session class should have a vector of Statement object pointers which
69
 * comprise the statements executed on the Session. Until this architectural
70
 * change is done, we can forget about parallel operations inside a session.
1100.3.29 by Padraig O'Sullivan
Removed the Statement class. Copied any members it had that were needed by
71
 *
72
 * @todo
73
 *
74
 * Make member variables private and have inlined accessors and setters.  Hide
75
 * all member variables that are not critical to non-internal operations of the
76
 * session object.
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.
77
 */
1823.6.1 by Brian Aker
First pass through adding back user_locks.
78
2263.3.11 by Olaf van der Spek
Open Tables
79
class Open_tables_state;
80
2263.3.10 by Olaf van der Spek
Open Tables
81
class DRIZZLED_API Session
1 by brian
clean slate
82
{
2241.3.1 by Olaf van der Spek
Refactor Session::status_var
83
private:
84
  class impl_c;
85
86
  boost::scoped_ptr<impl_c> impl_;
1 by brian
clean slate
87
public:
1932.3.5 by Brian Aker
Finish change so that we use a shared_ptr for the session list.
88
  typedef boost::shared_ptr<Session> shared_ptr;
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
89
2241.3.14 by Olaf van der Spek
Refactor
90
  static shared_ptr make_shared(plugin::Client *client, boost::shared_ptr<catalog::Instance> instance_arg)
2039.6.3 by Brian Aker
Update for session to have a catalog object.
91
  {
2039.6.4 by Brian Aker
Merge in local_instance change.
92
    assert(instance_arg);
2039.6.3 by Brian Aker
Update for session to have a catalog object.
93
    return boost::make_shared<Session>(client, instance_arg);
94
  }
95
1 by brian
clean slate
96
  /*
97
    MARK_COLUMNS_NONE:  Means mark_used_colums is not set and no indicator to
98
                        handler of fields used is set
99
    MARK_COLUMNS_READ:  Means a bit in read set is set to inform handler
100
	                that the field is to be read. If field list contains
520.1.22 by Brian Aker
Second pass of thd cleanup
101
                        duplicates, then session->dup_field is set to point
1 by brian
clean slate
102
                        to the last found duplicate.
103
    MARK_COLUMNS_WRITE: Means a bit is set in write set to inform handler
104
			that it needs to update this field in write_row
105
                        and update_row.
106
  */
2241.3.6 by Olaf van der Spek
Refactor
107
  enum_mark_columns mark_used_columns;
2148.7.8 by Brian Aker
Remove bits from Session where was providing a service directly.
108
1100.3.29 by Padraig O'Sullivan
Removed the Statement class. Copied any members it had that were needed by
109
  /** Frees all items attached to this Statement */
110
  void free_items();
2148.7.8 by Brian Aker
Remove bits from Session where was providing a service directly.
111
1100.3.29 by Padraig O'Sullivan
Removed the Statement class. Copied any members it had that were needed by
112
  /**
113
   * List of items created in the parser for this query. Every item puts
114
   * itself to the list on creation (see Item::Item() for details))
115
   */
116
  Item *free_list;
2318.6.20 by Olaf van der Spek
Refactor
117
  memory::Root& mem;
118
  memory::Root* mem_root; /**< Pointer to current memroot */
1532.1.10 by Brian Aker
Encapsulation of mem_root for session/this switches the creation of new_path
119
2385.2.4 by Olaf van der Spek
cppcheck
120
  uint64_t getXaId() const
1856.2.7 by Joseph Daly
create schema changes
121
  {
122
    return xa_id;
123
  }
124
125
  void setXaId(uint64_t in_xa_id)
126
  {
2221.11.1 by Olaf van der Spek
Session::getLex()
127
    xa_id= in_xa_id;
1856.2.7 by Joseph Daly
create schema changes
128
  }
129
2187.2.2 by Brian Aker
getLex() usage and fix for table_name creation during admin commands.
130
public:
2239.1.4 by Olaf van der Spek
Refactor includes
131
  Diagnostics_area& main_da();
2234.1.1 by Olaf van der Spek
Refactor includes
132
  const LEX& lex() const;
133
  LEX& lex();
134
  enum_sql_command getSqlCommand() const;
2151.7.4 by Stewart Smith
properly encapsulate Session::Lex->sql_command and stop using (and remove) session_sql_command(session)
135
1280.3.11 by Padraig O'Sullivan
Changed the query member of Session to be std::string
136
  /** query associated with this statement */
1921.4.14 by Brian Aker
Update to tighten up query string.
137
  typedef boost::shared_ptr<const std::string> QueryString;
2148.7.4 by Brian Aker
Move out property map to its own files.
138
1921.4.13 by Brian Aker
Fix issue where session info might not be correct.
139
private:
1921.4.14 by Brian Aker
Update to tighten up query string.
140
  boost::shared_ptr<std::string> query;
1921.4.13 by Brian Aker
Fix issue where session info might not be correct.
141
142
  // Never allow for a modification of this outside of the class. c_str()
143
  // requires under some setup non const, you must copy the QueryString in
144
  // order to use it.
145
public:
2269.1.8 by Olaf van der Spek
Refactor Session
146
  void resetQueryString();
147
  const boost::shared_ptr<session::State>& state();
148
1921.4.14 by Brian Aker
Update to tighten up query string.
149
  QueryString getQueryString() const
1921.4.13 by Brian Aker
Fix issue where session info might not be correct.
150
  {
151
    return query;
152
  }
153
2269.1.8 by Olaf van der Spek
Refactor Session
154
  const char* getQueryStringCopy(size_t &length)
1921.4.13 by Brian Aker
Fix issue where session info might not be correct.
155
  {
156
    QueryString tmp_string(getQueryString());
1976.5.1 by Brian Aker
This fixes the issue of a crash because of one thread touching the session
157
    if (not tmp_string)
158
    {
159
      length= 0;
2003.1.3 by Andrew Hutchings
Re-fix after discussion with Krow
160
      return NULL;
1976.5.1 by Brian Aker
This fixes the issue of a crash because of one thread touching the session
161
    }
1921.4.13 by Brian Aker
Fix issue where session info might not be correct.
162
    length= tmp_string->length();
2318.9.10 by Olaf van der Spek
Rename strmake to strdup (standard name)
163
    return mem.strdup(*tmp_string);
2269.1.8 by Olaf van der Spek
Refactor Session
164
  }
1921.4.7 by Brian Aker
Test for issues on CONCURRENT to be sure it operates in a single
165
2269.1.7 by Olaf van der Spek
Use util::string::ptr
166
  util::string::ptr schema() const;
2039.6.4 by Brian Aker
Merge in local_instance change.
167
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.
168
  /**
520.1.21 by Brian Aker
THD -> Session rename
169
    Constant for Session::where initialization in the beginning of every query.
1 by brian
clean slate
170
520.1.21 by Brian Aker
THD -> Session rename
171
    It's needed because we do not save/restore Session::where normally during
1 by brian
clean slate
172
    primary (non subselect) query execution.
173
  */
2318.6.43 by Olaf van der Spek
Refactor
174
  static const char* const DEFAULT_WHERE;
1 by brian
clean slate
175
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
176
  memory::Root warn_root; /**< Allocation area for warnings and errors */
2015.3.1 by Brian Aker
Encapsulate client call. Also remove the need to call current_session when
177
public:
1921.4.1 by Brian Aker
Adding in support for EXECUTE to have WITH NO RETURN.
178
  void setClient(plugin::Client *client_arg);
179
2104.1.1 by Brian Aker
Merge in update to use console for catalog DDL.
180
  plugin::Client *getClient() const
181
  {
182
    return client;
183
  }
184
2318.6.43 by Olaf van der Spek
Refactor
185
  plugin::Scheduler* scheduler; /**< Pointer to scheduler object */
1927.2.1 by Brian Aker
Merge up the tree.
186
2318.6.43 by Olaf van der Spek
Refactor
187
  typedef boost::unordered_map<std::string, user_var_entry*, util::insensitive_hash, util::insensitive_equal_to> UserVars;
2148.7.4 by Brian Aker
Move out property map to its own files.
188
1927.2.1 by Brian Aker
Merge up the tree.
189
private:
1689.3.4 by Brian Aker
Remove the hash in session, for a boost based one.
190
  typedef std::pair< UserVars::iterator, UserVars::iterator > UserVarsRange;
191
  UserVars user_vars; /**< Hash of user variables defined during the session's lifetime */
192
193
public:
1927.2.1 by Brian Aker
Merge up the tree.
194
  const UserVars &getUserVariables() const
195
  {
196
    return user_vars;
197
  }
198
2241.3.2 by Olaf van der Spek
Refactor Session::variables
199
  drizzle_system_variables& variables; /**< Mutable local variables local to the session */
2385.3.6 by Olaf van der Spek
cppcheck
200
  enum_tx_isolation getTxIsolation() const;
2241.3.1 by Olaf van der Spek
Refactor Session::status_var
201
  system_status_var& status_var;
2239.1.9 by Olaf van der Spek
Refactor includes
202
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.
203
  THR_LOCK_INFO lock_info; /**< Locking information for this session */
204
  THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
205
  THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
1039.1.16 by Brian Aker
A lot of little cleanups (most based off lcov)
206
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.
207
  /**
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.
208
   * A pointer to the stack frame of the scheduler thread
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.
209
   * which is called first in the thread for handling a client
210
   */
1039.1.16 by Brian Aker
A lot of little cleanups (most based off lcov)
211
  char *thread_stack;
1 by brian
clean slate
212
2252.1.8 by Olaf van der Spek
Common fwd
213
  identifier::user::ptr user() const
1273.11.5 by Dennis Schoen
add getSecurityContext()
214
  {
2318.8.8 by Olaf van der Spek
Refactor Scoreboard
215
    return security_ctx;
1273.11.5 by Dennis Schoen
add getSecurityContext()
216
  }
1 by brian
clean slate
217
2252.1.8 by Olaf van der Spek
Common fwd
218
  void setUser(identifier::user::mptr arg)
1273.11.7 by Dennis Schoen
add second getSecurityContext() function that returns a non-const refernce
219
  {
2008.1.1 by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency
220
    security_ctx= arg;
1273.11.7 by Dennis Schoen
add second getSecurityContext() function that returns a non-const refernce
221
  }
222
2318.8.8 by Olaf van der Spek
Refactor Scoreboard
223
  int32_t getScoreboardIndex() const
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
224
  {
225
    return scoreboard_index;
226
  }
227
228
  void setScoreboardIndex(int32_t in_scoreboard_index)
229
  {
230
    scoreboard_index= in_scoreboard_index;
231
  }
232
2385.2.4 by Olaf van der Spek
cppcheck
233
  bool isOriginatingServerUUIDSet() const
2290.1.2 by Joseph Daly
server uuid as part of replication table
234
  {
235
    return originating_server_uuid_set;
236
  }
237
238
  void setOriginatingServerUUID(std::string in_originating_server_uuid)
239
  {
240
    originating_server_uuid= in_originating_server_uuid;
241
    originating_server_uuid_set= true;
242
  }
243
2385.2.4 by Olaf van der Spek
cppcheck
244
  const std::string &getOriginatingServerUUID() const
2290.1.2 by Joseph Daly
server uuid as part of replication table
245
  {
246
    return originating_server_uuid;
247
  }
248
249
  void setOriginatingCommitID(uint64_t in_originating_commit_id)
250
  {
251
    originating_commit_id= in_originating_commit_id;
252
  }
253
2385.2.4 by Olaf van der Spek
cppcheck
254
  uint64_t getOriginatingCommitID() const
2290.1.2 by Joseph Daly
server uuid as part of replication table
255
  {
256
    return originating_commit_id;
257
  }
258
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.
259
  /**
1317.2.11 by Monty Taylor
Moved isViewable check in to Session.h.
260
   * Is this session viewable by the current user?
261
   */
2246.4.11 by Olaf van der Spek
Remove const_reference and reference from identifier::User
262
  bool isViewable(const identifier::User&) const;
1317.2.11 by Monty Taylor
Moved isViewable check in to Session.h.
263
2114.4.10 by Brian Aker
Remove current_session from a couple of locations, encapsulate where in
264
private:
1317.2.11 by Monty Taylor
Moved isViewable check in to Session.h.
265
  /**
1 by brian
clean slate
266
    Used in error messages to tell user in what part of MySQL we found an
267
    error. E. g. when where= "having clause", if fix_fields() fails, user
268
    will know that the error was in having clause.
269
  */
2114.4.10 by Brian Aker
Remove current_session from a couple of locations, encapsulate where in
270
  const char *_where;
271
272
public:
2385.2.4 by Olaf van der Spek
cppcheck
273
  const char *where() const
2114.4.10 by Brian Aker
Remove current_session from a couple of locations, encapsulate where in
274
  {
275
    return _where;
276
  }
277
278
  void setWhere(const char *arg)
279
  {
280
    _where= arg;
281
  }
1 by brian
clean slate
282
283
  /*
284
    One thread can hold up to one named user-level lock. This variable
285
    points to a lock object if the lock is present. See item_func.cc and
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
286
    chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK.
1 by brian
clean slate
287
  */
2114.4.10 by Brian Aker
Remove current_session from a couple of locations, encapsulate where in
288
1775.4.4 by Brian Aker
Cleanup my_thread_var usage.
289
private:
1933.2.1 by Brian Aker
Added a sessions table function, and a "THREAD_ID" column to it.
290
  boost::thread::id boost_thread_id;
2275.3.3 by Olaf van der Spek
Thread
291
  thread_ptr _thread;
1933.2.4 by Brian Aker
Update user locks to allow for interruption based on boost.
292
  boost::this_thread::disable_interruption *interrupt;
1933.2.1 by Brian Aker
Added a sessions table function, and a "THREAD_ID" column to it.
293
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
294
  internal::st_my_thread_var *mysys_var;
2148.7.4 by Brian Aker
Move out property map to its own files.
295
1775.4.4 by Brian Aker
Cleanup my_thread_var usage.
296
public:
2275.3.3 by Olaf van der Spek
Thread
297
  thread_ptr &getThread()
1933.2.3 by Brian Aker
Have session store a copy of its current thread.
298
  {
299
    return _thread;
1933.2.1 by Brian Aker
Added a sessions table function, and a "THREAD_ID" column to it.
300
  }
301
1933.2.4 by Brian Aker
Update user locks to allow for interruption based on boost.
302
  void pushInterrupt(boost::this_thread::disable_interruption *interrupt_arg)
303
  {
304
    interrupt= interrupt_arg;
305
  }
306
307
  boost::this_thread::disable_interruption &getThreadInterupt()
308
  {
309
    assert(interrupt);
310
    return *interrupt;
311
  }
312
1775.4.4 by Brian Aker
Cleanup my_thread_var usage.
313
  internal::st_my_thread_var *getThreadVar()
314
  {
315
    return mysys_var;
316
  }
317
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.
318
  /**
319
   * Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
320
   * first byte of the packet in executeStatement()
321
   */
2269.1.2 by Olaf van der Spek
Session Times
322
  enum_server_command command;
2269.1.4 by Olaf van der Spek
Session Times
323
1 by brian
clean slate
324
  thr_lock_type update_lock_default;
325
661 by Brian Aker
First major pass through new replication.
326
  /*
327
    Both of the following container points in session will be converted to an API.
328
  */
329
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)
330
private:
1 by brian
clean slate
331
  /* container for handler's private per-connection data */
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
332
  std::vector<Ha_data> ha_data;
1273.1.1 by Jay Pipes
* Changes Session::warn_id to Session::warn_query_id
333
  /*
334
    Id of current query. Statement can be reused to execute several queries
335
    query_id is global in context of the whole MySQL server.
336
    ID is automatically generated from an atomic counter.
337
    It's used in Cursor code for various purposes: to check which columns
338
    from table are necessary for this select, to check if it's necessary to
339
    update auto-updatable fields (like auto_increment and timestamp).
340
  */
341
  query_id_t query_id;
342
  query_id_t warn_query_id;
2040.4.2 by Brian Aker
First pass on removing some of the calls currently to boost::posix_time. (we
343
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)
344
public:
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
345
  void **getEngineData(const plugin::MonitoredInTransaction *monitored);
2241.2.9 by Olaf van der Spek
Refactor
346
  ResourceContext& getResourceContext(const plugin::MonitoredInTransaction&, size_t index= 0);
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)
347
2241.3.4 by Olaf van der Spek
Refactor Session::transaction
348
  session::Transactions& transaction;
2263.3.2 by Olaf van der Spek
Use open_tables
349
  Open_tables_state& open_tables;
2269.1.3 by Olaf van der Spek
Session Times
350
	session::Times& times;
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
351
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.
352
  Field *dup_field;
1 by brian
clean slate
353
  sigset_t signals;
354
2227.4.12 by Olaf van der Spek
Refactor Session
355
public:
1921.4.2 by Brian Aker
Adding in concurrent execute support.
356
  // As of right now we do not allow a concurrent execute to launch itself
357
  void setConcurrentExecute(bool arg)
358
  {
359
    concurrent_execute_allowed= arg;
360
  }
361
362
  bool isConcurrentExecuteAllowed() const
363
  {
364
    return concurrent_execute_allowed;
365
  }
366
1 by brian
clean slate
367
  /*
368
    ALL OVER THIS FILE, "insert_id" means "*automatically generated* value for
369
    insertion into an auto_increment column".
370
  */
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.
371
  /**
1 by brian
clean slate
372
    This is the first autogenerated insert id which was *successfully*
373
    inserted by the previous statement (exactly, if the previous statement
374
    didn't successfully insert an autogenerated insert id, then it's the one
375
    of the statement before, etc).
376
    It can also be set by SET LAST_INSERT_ID=# or SELECT LAST_INSERT_ID(#).
377
    It is returned by LAST_INSERT_ID().
378
  */
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.
379
  uint64_t first_successful_insert_id_in_prev_stmt;
380
  /**
1 by brian
clean slate
381
    This is the first autogenerated insert id which was *successfully*
382
    inserted by the current statement. It is maintained only to set
383
    first_successful_insert_id_in_prev_stmt when statement ends.
384
  */
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.
385
  uint64_t first_successful_insert_id_in_cur_stmt;
386
  /**
1 by brian
clean slate
387
    We follow this logic:
388
    - when stmt starts, first_successful_insert_id_in_prev_stmt contains the
389
    first insert id successfully inserted by the previous stmt.
390
    - as stmt makes progress, handler::insert_id_for_cur_row changes;
391
    every time get_auto_increment() is called,
392
    auto_inc_intervals_in_cur_stmt_for_binlog is augmented with the
393
    reserved interval (if statement-based binlogging).
394
    - at first successful insertion of an autogenerated value,
395
    first_successful_insert_id_in_cur_stmt is set to
396
    handler::insert_id_for_cur_row.
397
    - when stmt goes to binlog,
398
    auto_inc_intervals_in_cur_stmt_for_binlog is binlogged if
399
    non-empty.
400
    - when stmt ends, first_successful_insert_id_in_prev_stmt is set to
401
    first_successful_insert_id_in_cur_stmt.
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.
402
1 by brian
clean slate
403
    List of auto_increment intervals reserved by the thread so far, for
404
    storage in the statement-based binlog.
405
    Note that its minimum is not first_successful_insert_id_in_cur_stmt:
406
    assuming a table with an autoinc column, and this happens:
407
    INSERT INTO ... VALUES(3);
408
    SET INSERT_ID=3; INSERT IGNORE ... VALUES (NULL);
409
    then the latter INSERT will insert no rows
410
    (first_successful_insert_id_in_cur_stmt == 0), but storing "INSERT_ID=3"
411
    in the binlog is still needed; the list's minimum will contain 3.
412
  */
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.
413
414
  uint64_t limit_found_rows;
1055.2.15 by Jay Pipes
Removed unused cached character set variables in Session along with dead update_charset() method.
415
  uint64_t options; /**< Bitmap of options */
416
  int64_t row_count_func; /**< For the ROW_COUNT() function */
2148.5.2 by Brian Aker
Additional remove of current_session.
417
418
  int64_t rowCount() const
419
  {
420
    return row_count_func;
421
  }
422
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.
423
  ha_rows cuted_fields; /**< Count of "cut" or truncated fields. @todo Kill this friggin thing. */
424
2221.11.1 by Olaf van der Spek
Session::getLex()
425
  /**
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.
426
   * Number of rows we actually sent to the client, including "synthetic"
427
   * rows in ROLLUP etc.
428
   */
429
  ha_rows sent_row_count;
430
431
  /**
432
   * Number of rows we read, sent or not, including in create_sort_index()
433
   */
434
  ha_rows examined_row_count;
435
436
  /**
437
   * The set of those tables whose fields are referenced in all subqueries
438
   * of the query.
439
   *
440
   * @todo
2221.11.1 by Olaf van der Spek
Session::getLex()
441
   *
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.
442
   * Possibly this it is incorrect to have used tables in Session because
443
   * with more than one subquery, it is not clear what does the field mean.
444
   */
445
  table_map used_tables;
446
447
  /**
448
    @todo
2221.11.1 by Olaf van der Spek
Session::getLex()
449
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.
450
    This, and some other variables like 'count_cuted_fields'
1 by brian
clean slate
451
    maybe should be statement/cursor local, that is, moved to Statement
452
    class. With current implementation warnings produced in each prepared
453
    statement/cursor settle here.
454
  */
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.
455
  uint32_t warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END];
456
  uint32_t total_warn_count;
1 by brian
clean slate
457
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.
458
  /**
1 by brian
clean slate
459
    Row counter, mainly for errors and warnings. Not increased in
460
    create_sort_index(); may differ from examined_row_count.
461
  */
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.
462
  uint32_t row_count;
2015.1.3 by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED
463
1823.6.1 by Brian Aker
First pass through adding back user_locks.
464
  session_id_t thread_id;
1046.1.7 by Brian Aker
Style cleanup.
465
  uint32_t tmp_table;
1910.2.2 by Brian Aker
First pass through the global lock refactor merge.
466
  enum global_read_lock_t
467
  {
468
    NONE= 0,
469
    GOT_GLOBAL_READ_LOCK= 1,
470
    MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= 2
471
  };
472
private:
473
  global_read_lock_t _global_read_lock;
474
475
public:
476
477
  global_read_lock_t isGlobalReadLock() const
478
  {
479
    return _global_read_lock;
480
  }
481
482
  void setGlobalReadLock(global_read_lock_t arg)
483
  {
484
    _global_read_lock= arg;
485
  }
486
2064.1.2 by Brian Aker
Remove not_used bit for lock.
487
  DrizzleLock *lockTables(Table **tables, uint32_t count, uint32_t flags);
1910.2.3 by Brian Aker
Second pass on move code to global lock encapsulation.
488
  bool lockGlobalReadLock();
489
  bool lock_table_names(TableList *table_list);
490
  bool lock_table_names_exclusively(TableList *table_list);
491
  bool makeGlobalReadLockBlockCommit();
1910.2.7 by Brian Aker
Rename lock methods to be style + well make sense.
492
  bool abortLockForThread(Table *table);
1910.2.3 by Brian Aker
Second pass on move code to global lock encapsulation.
493
  bool wait_if_global_read_lock(bool abort_on_refresh, bool is_not_commit);
1910.2.4 by Brian Aker
Push some functions behind classes.
494
  int lock_table_name(TableList *table_list);
1910.2.7 by Brian Aker
Rename lock methods to be style + well make sense.
495
  void abortLock(Table *table);
496
  void removeLock(Table *table);
497
  void unlockReadTables(DrizzleLock *sql_lock);
498
  void unlockSomeTables(Table **table, uint32_t count);
499
  void unlockTables(DrizzleLock *sql_lock);
1910.2.3 by Brian Aker
Second pass on move code to global lock encapsulation.
500
  void startWaitingGlobalReadLock();
1910.2.2 by Brian Aker
First pass through the global lock refactor merge.
501
  void unlockGlobalReadLock();
1910.2.3 by Brian Aker
Second pass on move code to global lock encapsulation.
502
503
private:
504
  int unlock_external(Table **table, uint32_t count);
505
  int lock_external(Table **tables, uint32_t count);
1910.2.4 by Brian Aker
Push some functions behind classes.
506
  bool wait_for_locked_table_names(TableList *table_list);
507
  DrizzleLock *get_lock_data(Table **table_ptr, uint32_t count,
508
                             bool should_lock, Table **write_lock_used);
1910.2.3 by Brian Aker
Second pass on move code to global lock encapsulation.
509
public:
1910.2.2 by Brian Aker
First pass through the global lock refactor merge.
510
1046.1.7 by Brian Aker
Style cleanup.
511
  uint32_t server_status;
512
  uint32_t open_options;
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.
513
  uint32_t select_number; /**< number of select (used for EXPLAIN) */
1 by brian
clean slate
514
  /* variables.transaction_isolation is reset to this after each commit */
515
  enum_tx_isolation session_tx_isolation;
516
  enum_check_fields count_cuted_fields;
517
1910.2.8 by Brian Aker
Enapsulate Kill.
518
  enum killed_state_t
1 by brian
clean slate
519
  {
550 by Monty Taylor
Moved error.h into just the files that need it.
520
    NOT_KILLED,
521
    KILL_BAD_DATA,
522
    KILL_CONNECTION,
523
    KILL_QUERY,
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.
524
    KILLED_NO_VALUE /* means none of the above states apply */
1 by brian
clean slate
525
  };
1910.2.8 by Brian Aker
Enapsulate Kill.
526
private:
527
  killed_state_t volatile _killed;
528
529
public:
530
531
  void setKilled(killed_state_t arg)
532
  {
533
    _killed= arg;
534
  }
535
2385.2.4 by Olaf van der Spek
cppcheck
536
  killed_state_t getKilled() const
1910.2.8 by Brian Aker
Enapsulate Kill.
537
  {
538
    return _killed;
539
  }
540
541
  volatile killed_state_t *getKilledPtr() // Do not use this method, it is here for historical convience.
542
  {
543
    return &_killed;
544
  }
1 by brian
clean slate
545
1960.2.1 by Andrew Hutchings
Add admin connection to client/server protocols
546
  bool is_admin_connection;
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.
547
  bool no_errors;
1 by brian
clean slate
548
  /**
51.1.50 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
549
    Set to true if execution of the current compound statement
1 by brian
clean slate
550
    can not continue. In particular, disables activation of
551
    CONTINUE or EXIT handlers of stored routines.
552
    Reset in the end of processing of the current user request, in
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
553
    @see reset_session_for_next_command().
1 by brian
clean slate
554
  */
555
  bool is_fatal_error;
556
  /**
557
    Set by a storage engine to request the entire
558
    transaction (that possibly spans multiple engines) to
559
    rollback. Reset in ha_rollback.
560
  */
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.
561
  bool transaction_rollback_request;
1 by brian
clean slate
562
  /**
51.1.50 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
563
    true if we are in a sub-statement and the current error can
1 by brian
clean slate
564
    not be safely recovered until we left the sub-statement mode.
565
    In particular, disables activation of CONTINUE and EXIT
566
    handlers inside sub-statements. E.g. if it is a deadlock
567
    error and requires a transaction-wide rollback, this flag is
568
    raised (traditionally, MySQL first has to close all the reads
569
    via @see handler::ha_index_or_rnd_end() and only then perform
570
    the rollback).
51.1.50 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
571
    Reset to false when we leave the sub-statement mode.
1 by brian
clean slate
572
  */
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.
573
  bool is_fatal_sub_stmt_error;
574
  /** for IS NULL => = last_insert_id() fix in remove_eq_conds() */
575
  bool substitute_null_with_insert_id;
576
  bool cleanup_done;
577
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
578
public:
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.
579
  bool got_warning; /**< Set on call to push_warning() */
580
  bool no_warnings_for_error; /**< no warnings on call to my_error() */
581
  /** set during loop of derived table processing */
582
  bool derived_tables_processing;
2151.7.2 by Stewart Smith
properly encapsulate Session::tablespace_op and stop using (and remove) session_tablespace_op(session)
583
2385.2.4 by Olaf van der Spek
cppcheck
584
  bool doing_tablespace_operation() const
2151.7.2 by Stewart Smith
properly encapsulate Session::tablespace_op and stop using (and remove) session_tablespace_op(session)
585
  {
586
    return tablespace_op;
587
  }
588
2151.7.9 by Stewart Smith
switch doing_tablespace_operation to doingTablespaceOperation and set_doing_tablespace_operation to setDoingTablespaceOperation
589
  void setDoingTablespaceOperation(bool doing)
2151.7.2 by Stewart Smith
properly encapsulate Session::tablespace_op and stop using (and remove) session_tablespace_op(session)
590
  {
591
    tablespace_op= doing;
592
  }
593
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.
594
595
  /** Used by the sys_var class to store temporary values */
1 by brian
clean slate
596
  union
597
  {
1055.2.17 by Jay Pipes
More style cleanups in Session
598
    bool bool_value;
599
    uint32_t uint32_t_value;
600
    int32_t int32_t_value;
151 by Brian Aker
Ulonglong to uint64_t
601
    uint64_t uint64_t_value;
1 by brian
clean slate
602
  } sys_var_tmp;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
603
1 by brian
clean slate
604
  /**
605
    Character input stream consumed by the lexical analyser,
606
    used during parsing.
607
    Note that since the parser is not re-entrant, we keep only one input
608
    stream here. This member is valid only when executing code during parsing,
609
    and may point to invalid memory after that.
610
  */
611
  Lex_input_stream *m_lip;
2221.11.1 by Olaf van der Spek
Session::getLex()
612
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.
613
  /** Place to store various things */
614
  void *session_marker;
1183.1.29 by Brian Aker
Clean up interface so that Truncate sets the propper engine when
615
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.
616
  /**
617
    Points to info-string that we show in SHOW PROCESSLIST
618
    You are supposed to call Session_SET_PROC_INFO only if you have coded
619
    a time-consuming piece that MySQL can get stuck in for a long time.
620
621
    Set it using the  session_proc_info(Session *thread, const char *message)
622
    macro/function.
623
  */
624
  inline void set_proc_info(const char *info)
2221.11.1 by Olaf van der Spek
Session::getLex()
625
  {
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.
626
    proc_info= info;
627
  }
628
  inline const char* get_proc_info() const
629
  {
630
    return proc_info;
631
  }
632
1273.1.1 by Jay Pipes
* Changes Session::warn_id to Session::warn_query_id
633
  /** Sets this Session's current query ID */
634
  inline void setQueryId(query_id_t in_query_id)
635
  {
636
    query_id= in_query_id;
637
  }
638
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.
639
  /** Returns the current query ID */
1922.1.1 by Brian Aker
Move temp tables down to open_table class. (first pass)
640
  query_id_t getQueryId()  const
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.
641
  {
642
    return query_id;
643
  }
644
1273.1.1 by Jay Pipes
* Changes Session::warn_id to Session::warn_query_id
645
646
  /** Sets this Session's warning query ID */
647
  inline void setWarningQueryId(query_id_t in_query_id)
648
  {
649
    warn_query_id= in_query_id;
650
  }
651
652
  /** Returns the Session's warning query ID */
653
  inline query_id_t getWarningQueryId()  const
654
  {
655
    return warn_query_id;
656
  }
657
1039.5.56 by Jay Pipes
Adds Session ID accessor, and output to replication messages
658
  /** Accessor method returning the session's ID. */
1823.6.1 by Brian Aker
First pass through adding back user_locks.
659
  inline session_id_t getSessionId()  const
1039.5.56 by Jay Pipes
Adds Session ID accessor, and output to replication messages
660
  {
661
    return thread_id;
662
  }
663
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.
664
  /** Accessor method returning the server's ID. */
665
  inline uint32_t getServerId()  const
666
  {
667
    /* We return the global server ID. */
668
    return server_id;
669
  }
670
2290.1.1 by Joseph Daly
Add server uuid
671
  inline std::string &getServerUUID() const
672
  {
673
    return server_uuid;
674
  }
675
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.
676
  /**
677
    There is BUG#19630 where statement-based replication of stored
678
    functions/triggers with two auto_increment columns breaks.
679
    We however ensure that it works when there is 0 or 1 auto_increment
680
    column; our rules are
681
    a) on master, while executing a top statement involving substatements,
682
    first top- or sub- statement to generate auto_increment values wins the
683
    exclusive right to see its values be written to binlog (the write
684
    will be done by the statement or its caller), and the losers won't see
685
    their values be written to binlog.
686
    b) on slave, while replicating a top statement involving substatements,
687
    first top- or sub- statement to need to read auto_increment values from
688
    the master's binlog wins the exclusive right to read them (so the losers
689
    won't read their values from binlog but instead generate on their own).
690
    a) implies that we mustn't backup/restore
691
    auto_inc_intervals_in_cur_stmt_for_binlog.
692
    b) implies that we mustn't backup/restore auto_inc_intervals_forced.
693
694
    If there are more than 1 auto_increment columns, then intervals for
695
    different columns may mix into the
696
    auto_inc_intervals_in_cur_stmt_for_binlog list, which is logically wrong,
697
    but there is no point in preventing this mixing by preventing intervals
698
    from the secondly inserted column to come into the list, as such
699
    prevention would be wrong too.
700
    What will happen in the case of
701
    INSERT INTO t1 (auto_inc) VALUES(NULL);
702
    where t1 has a trigger which inserts into an auto_inc column of t2, is
703
    that in binlog we'll store the interval of t1 and the interval of t2 (when
704
    we store intervals, soon), then in slave, t1 will use both intervals, t2
705
    will use none; if t1 inserts the same number of rows as on master,
706
    normally the 2nd interval will not be used by t1, which is fine. t2's
707
    values will be wrong if t2's internal auto_increment counter is different
708
    from what it was on master (which is likely). In 5.1, in mixed binlogging
709
    mode, row-based binlogging is used for such cases where two
710
    auto_increment columns are inserted.
711
  */
712
  inline void record_first_successful_insert_id_in_cur_stmt(uint64_t id_arg)
713
  {
714
    if (first_successful_insert_id_in_cur_stmt == 0)
715
      first_successful_insert_id_in_cur_stmt= id_arg;
716
  }
2385.2.4 by Olaf van der Spek
cppcheck
717
  inline uint64_t read_first_successful_insert_id_in_prev_stmt() const
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.
718
  {
719
    return first_successful_insert_id_in_prev_stmt;
720
  }
1 by brian
clean slate
721
2318.6.43 by Olaf van der Spek
Refactor
722
  Session(plugin::Client*, boost::shared_ptr<catalog::Instance>);
723
  ~Session();
1 by brian
clean slate
724
2227.4.11 by Olaf van der Spek
Refactor Session
725
  void cleanup();
1055.2.24 by Jay Pipes
Merge with trunk and resolve conflicts.
726
  /**
727
   * Cleans up after query.
728
   *
729
   * @details
730
   *
731
   * This function is used to reset thread data to its default state.
732
   *
733
   * This function is not suitable for setting thread data to some
734
   * non-default values, as there is only one replication thread, so
735
   * different master threads may overwrite data of each other on
736
   * slave.
737
   */
1 by brian
clean slate
738
  void cleanup_after_query();
2269.1.7 by Olaf van der Spek
Use util::string::ptr
739
  void storeGlobals();
1910.2.8 by Brian Aker
Enapsulate Kill.
740
  void awake(Session::killed_state_t state_to_set);
934.2.6 by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h
741
742
  /**
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.
743
    Initialize memory roots necessary for query processing and (!)
744
    pre-allocate memory for it. We can't do that in Session constructor because
971.3.70 by Eric Day
Fixed style issues found by Jay.
745
    there are use cases where it's vital to not allocate excessive and not used
746
    memory.
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
  */
934.2.6 by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h
748
  void prepareForQueries();
1 by brian
clean slate
749
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...
750
  /**
2221.11.1 by Olaf van der Spek
Session::getLex()
751
   * Executes a single statement received from the
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.
752
   * client connection.
753
   *
2221.11.1 by Olaf van der Spek
Session::getLex()
754
   * Returns true if the statement was successful, or false
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.
755
   * otherwise.
756
   *
757
   * @note
758
   *
759
   * For profiling to work, it must never be called recursively.
760
   *
761
   * In MySQL, this used to be the do_command() C function whic
762
   * accepted a single parameter of the THD pointer.
763
   */
764
  bool executeStatement();
765
766
  /**
934.2.9 by Jay Pipes
Pulls alloc_query() C function out of sql_parse.cc and adds readAndStoreQuery() member method of Session class.
767
   * Reads a query from packet and stores it.
768
   *
2221.11.1 by Olaf van der Spek
Session::getLex()
769
   * Returns true if query is read and allocated successfully,
934.2.9 by Jay Pipes
Pulls alloc_query() C function out of sql_parse.cc and adds readAndStoreQuery() member method of Session class.
770
   * false otherwise.  On a return of false, Session::fatal_error
771
   * is set.
772
   *
773
   * @note Used in COM_QUERY and COM_STMT_PREPARE.
774
   *
775
   * Sets the following Session variables:
776
   *  - query
777
   *  - query_length
778
   *
779
   * @param The packet pointer to read from
780
   * @param The length of the query to read
781
   */
2275.2.6 by Olaf van der Spek
Refactor
782
  void 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.
783
784
  /**
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.
785
   * Ends the current transaction and (maybe) begins the next.
786
   *
2221.11.1 by Olaf van der Spek
Session::getLex()
787
   * Returns true if the transaction completed successfully,
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.
788
   * otherwise false.
789
   *
790
   * @param Completion type
791
   */
792
  bool endTransaction(enum enum_mysql_completiontype completion);
793
  bool endActiveTransaction();
1206.1.3 by Brian Aker
Valgrind fix for startTransaction()
794
  bool startTransaction(start_transaction_option_t opt= START_TRANS_NO_OPTIONS);
2153.1.2 by Stewart Smith
replace mark_transaction_to_rollback() with Session::markTransactionForRollback()
795
  void markTransactionForRollback(bool all);
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.
796
797
  /**
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...
798
   * Authenticates users, with error reporting.
799
   *
800
   * Returns true on success, or false on failure.
801
   */
802
  bool 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.
803
  void run();
2318.6.43 by Olaf van der Spek
Refactor
804
  static bool schedule(const Session::shared_ptr&);
2269.1.4 by Olaf van der Spek
Session Times
805
  static void unlink(session_id_t&);
2318.6.43 by Olaf van der Spek
Refactor
806
  static void unlink(const Session::shared_ptr&);
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.
807
1 by brian
clean slate
808
  /*
809
    For enter_cond() / exit_cond() to work the mutex must be got before
810
    enter_cond(); this mutex is then released by exit_cond().
811
    Usage must be: lock mutex; enter_cond(); your code; exit_cond().
812
  */
1812.3.5 by Brian Aker
Move to boost condition_any
813
  const char* enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg);
1241.9.55 by Monty Taylor
Moved tree into drizzled/
814
  void exit_cond(const char* old_msg);
815
2227.4.11 by Olaf van der Spek
Refactor Session
816
  uint64_t found_rows() const
1 by brian
clean slate
817
  {
818
    return limit_found_rows;
819
  }
2040.4.3 by Brian Aker
Scale down the calls to universal_time().
820
934.2.28 by Jay Pipes
Renamed some things to our standards and made private methods private...
821
  /** Returns whether the session is currently inside a transaction */
2040.4.5 by Brian Aker
Merge in additional updates for time usage.
822
  bool inTransaction() const
1 by brian
clean slate
823
  {
824
    return server_status & SERVER_STATUS_IN_TRANS;
825
  }
2040.4.3 by Brian Aker
Scale down the calls to universal_time().
826
2385.2.7 by Olaf van der Spek
Use str_ref
827
  lex_string_t* make_lex_string(lex_string_t*, str_ref);
1 by brian
clean slate
828
2318.3.11 by Olaf van der Spek
Refactor
829
  void send_explain_fields(select_result*);
2040.4.3 by Brian Aker
Scale down the calls to universal_time().
830
2239.1.4 by Olaf van der Spek
Refactor includes
831
  void clear_error(bool full= false);
832
  void clearDiagnostics();
833
  bool is_error() const;
834
2269.1.4 by Olaf van der Spek
Session Times
835
  static const charset_info_st *charset() { return default_charset_info; }
1 by brian
clean slate
836
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.
837
  /**
1 by brian
clean slate
838
    Cleanup statement parse state (parse tree, lex) and execution
839
    state after execution of a non-prepared SQL statement.
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.
840
841
    @todo
842
843
    Move this to Statement::~Statement
1 by brian
clean slate
844
  */
845
  void end_statement();
846
  inline int killed_errno() const
847
  {
1910.2.8 by Brian Aker
Enapsulate Kill.
848
    killed_state_t killed_val; /* to cache the volatile 'killed' */
849
    return (killed_val= _killed) != KILL_BAD_DATA ? killed_val : 0;
1 by brian
clean slate
850
  }
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
851
  void send_kill_message() const;
51.1.50 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
852
  /* return true if we will abort query if we make a warning now */
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
853
  inline bool abortOnWarning()
854
  {
855
    return abort_on_warning;
856
  }
857
858
  inline void setAbortOnWarning(bool arg)
859
  {
860
    abort_on_warning= arg;
1 by brian
clean slate
861
  }
1689.2.26 by Brian Aker
More encapsulation of the thread var.
862
863
  void setAbort(bool arg);
864
  void lockOnSys();
1 by brian
clean slate
865
  void set_status_var_init();
2287 by Brian Aker
Merge in Olaf prune tree (with comment on set_db)
866
  /**
867
    Set the current database; use deep copy of C-string.
868
869
    @param new_db     a pointer to the new database name.
870
    @param new_db_len length of the new database name.
871
872
    Initialize the current database from a NULL-terminated string with
873
    length. If we run out of memory, we free the current database and
874
    return true.  This way the user will notice the error as there will be
875
    no current database selected (in addition to the error message set by
876
    malloc).
877
878
    @note This operation just sets {db, db_length}. Switching the current
879
    database usually involves other actions, like switching other database
880
    attributes including security context. In the future, this operation
881
    will be made private and more convenient interface will be provided.
882
  */
2385.1.7 by Olaf van der Spek
Rename set_db to set_schema
883
  void set_schema(const std::string&);
1 by brian
clean slate
884
885
  /*
886
    Copy the current database to the argument. Use the current arena to
887
    allocate memory for a deep copy: current database may be freed after
888
    a statement is parsed but before it's executed.
889
  */
2430.1.9 by Olaf van der Spek
Add const
890
  str_ref copy_db_to() const;
1 by brian
clean slate
891
892
public:
893
693 by Brian Aker
Cleaning up session class.
894
  /**
1055.2.24 by Jay Pipes
Merge with trunk and resolve conflicts.
895
    Resets Session part responsible for command processing state.
896
897
    This needs to be called before execution of every statement
898
    (prepared or conventional).
899
    It is not called by substatements of routines.
900
901
    @todo
902
    Make it a method of Session and align its name with the rest of
903
    reset/end/start/init methods.
904
    @todo
905
    Call it after we use Session for queries, not before.
735 by Brian Aker
Refactor session.
906
  */
907
  void reset_for_next_command();
908
909
  /**
934.2.6 by Jay Pipes
This changeset removes a few more C functions from sql_connect.cc/connect.h
910
   * Disconnects the session from a client connection and
911
   * updates any status variables necessary.
912
   *
913
   * @param errcode	Error code to print to console
914
   *
915
   * @note  For the connection that is doing shutdown, this is called twice
916
   */
2054.1.2 by Brian Aker
Rename of the Loooongggggg error type over to simply drizzled::error_t
917
  void disconnect(enum error_t errcode= EE_OK);
693 by Brian Aker
Cleaning up session class.
918
934.2.28 by Jay Pipes
Renamed some things to our standards and made private methods private...
919
  /**
920
   * Check if user exists and the password supplied is correct.
921
   *
922
   * Returns true on success, and false on failure.
923
   *
924
   * @note Host, user and passwd may point to communication buffer.
925
   * Current implementation does not depend on that, but future changes
2221.11.1 by Olaf van der Spek
Session::getLex()
926
   * should be done with this in mind;
934.2.28 by Jay Pipes
Renamed some things to our standards and made private methods private...
927
   *
1861.6.1 by David Shrewsbury
Add method to undo adding records to a Statement message in case of multi-row statement failure.
928
   * @param passwd Scrambled password received from client
929
   * @param db Database name to connect to, may be NULL
934.2.28 by Jay Pipes
Renamed some things to our standards and made private methods private...
930
   */
1857.4.1 by Monty Taylor
Added string sys_var type.
931
  bool checkUser(const std::string &passwd, const std::string &db);
2221.11.1 by Olaf van der Spek
Session::getLex()
932
1055.3.6 by Jay Pipes
Adds public getConnectMicroseconds() call to Session object. Protects connect_microseconds member variable and sets it correctly. Corrects logging_xxx plugins to use getConnectMicroseconds() API call properly. Fixes Bug #402855
933
  /**
1143.2.10 by Jay Pipes
Phase 2 new replication work:
934
   * Returns a pointer to the active Transaction message for this
935
   * Session being managed by the ReplicationServices component, or
936
   * NULL if no active message.
937
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
938
  message::Transaction *getTransactionMessage() const
1143.2.10 by Jay Pipes
Phase 2 new replication work:
939
  {
940
    return transaction_message;
941
  }
942
943
  /**
944
   * Returns a pointer to the active Statement message for this
945
   * Session, or NULL if no active message.
946
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
947
  message::Statement *getStatementMessage() const
1143.2.10 by Jay Pipes
Phase 2 new replication work:
948
  {
949
    return statement_message;
950
  }
2221.11.1 by Olaf van der Spek
Session::getLex()
951
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
952
  /**
953
   * Returns a pointer to the current Resulset message for this
954
   * Session, or NULL if no active message.
955
   */
956
  message::Resultset *getResultsetMessage() const
957
  {
958
    return resultset;
959
  }
1143.2.10 by Jay Pipes
Phase 2 new replication work:
960
  /**
961
   * Sets the active transaction message used by the ReplicationServices
962
   * component.
963
   *
964
   * @param[in] Pointer to the message
965
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
966
  void setTransactionMessage(message::Transaction *in_message)
1143.2.10 by Jay Pipes
Phase 2 new replication work:
967
  {
968
    transaction_message= in_message;
969
  }
970
971
  /**
972
   * Sets the active statement message used by the ReplicationServices
973
   * component.
974
   *
975
   * @param[in] Pointer to the message
976
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
977
  void setStatementMessage(message::Statement *in_message)
1143.2.10 by Jay Pipes
Phase 2 new replication work:
978
  {
979
    statement_message= in_message;
980
  }
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
981
982
  /**
983
   * Sets the active Resultset message used by the Query Cache
984
   * plugin.
985
   *
986
   * @param[in] Pointer to the message
987
   */
988
  void setResultsetMessage(message::Resultset *in_message)
989
  {
990
    resultset= in_message;
991
  }
1643.6.16 by Djellel E. Difallah
Fixing memory leaks
992
  /**
993
   * reset the active Resultset message used by the Query Cache
994
   * plugin.
995
   */
996
997
  void resetResultsetMessage()
2221.11.1 by Olaf van der Spek
Session::getLex()
998
  {
1643.6.16 by Djellel E. Difallah
Fixing memory leaks
999
    resultset= NULL;
1000
  }
1643.6.1 by Djellel E. Difallah
Added hook points and the interface for the Query Cache plugin
1001
2221.11.1 by Olaf van der Spek
Session::getLex()
1002
  plugin::EventObserverList *getSessionObservers()
1003
  {
1502.5.2 by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin.
1004
    return session_event_observers;
1005
  }
2221.11.1 by Olaf van der Spek
Session::getLex()
1006
1007
  void setSessionObservers(plugin::EventObserverList *observers)
1008
  {
1502.5.2 by Barry.Leslie at PrimeBase
Changes made to drizzle source when building in the events plugin.
1009
    session_event_observers= observers;
1010
  }
2221.11.1 by Olaf van der Spek
Session::getLex()
1011
2241.3.12 by Olaf van der Spek
Refactor Session
1012
  plugin::EventObserverList* getSchemaObservers(const std::string& schema);
1013
  plugin::EventObserverList* setSchemaObservers(const std::string& schema, plugin::EventObserverList*);
2221.11.1 by Olaf van der Spek
Session::getLex()
1014
836 by Brian Aker
Fixed session call from function to method.
1015
public:
2239.1.4 by Olaf van der Spek
Refactor includes
1016
  void my_ok(ha_rows affected_rows= 0, ha_rows found_rows_arg= 0, uint64_t passed_id= 0, const char *message= NULL);
1017
  void my_eof();
2318.6.31 by Olaf van der Spek
Refactor
1018
  void add_item_to_list(Item *item);
1019
  void add_value_to_list(Item *value);
1020
  void add_order_to_list(Item *item, bool asc);
1021
  void add_group_to_list(Item *item, bool asc);
2227.4.13 by Olaf van der Spek
Refactor Session
1022
855 by Brian Aker
Refactor reset of status.
1023
  void refresh_status();
2440.2.9 by Olaf van der Spek
Refactor
1024
  user_var_entry* getVariable(str_ref name, bool create_if_not_exists);
1025
  void setVariable(const std::string& name, const std::string& value);
2221.11.1 by Olaf van der Spek
Session::getLex()
1026
1055.2.24 by Jay Pipes
Merge with trunk and resolve conflicts.
1027
  /**
1028
   * Closes all tables used by the current substatement, or all tables
1029
   * used by this thread if we are on the upper level.
1030
   */
1039.1.16 by Brian Aker
A lot of little cleanups (most based off lcov)
1031
  void close_thread_tables();
2440.2.9 by Olaf van der Spek
Refactor
1032
  void close_old_data_files(bool morph_locks= false, bool send_refresh= false);
1033
  void close_data_files_and_morph_locks(const identifier::Table&);
1089.1.7 by Brian Aker
Shuffled free_cached_table() to table
1034
1055.2.24 by Jay Pipes
Merge with trunk and resolve conflicts.
1035
  /**
1036
   * Prepares statement for reopening of tables and recalculation of set of
1037
   * prelocked tables.
1038
   *
1039
   * @param Pointer to a pointer to a list of tables which we were trying to open and lock
1040
   */
1054.1.9 by Brian Aker
This is a large number of refactors against the Session class for its
1041
  void close_tables_for_reopen(TableList **tables);
1089.1.7 by Brian Aker
Shuffled free_cached_table() to table
1042
1043
1055.2.24 by Jay Pipes
Merge with trunk and resolve conflicts.
1044
  /**
1045
   * Open all tables in list, locks them (all, including derived)
1046
   *
1047
   * @param Pointer to a list of tables for open & locking
1048
   *
1049
   * @retval
1050
   *  false - ok
1051
   * @retval
1052
   *  true  - error
1053
   *
1054
   * @note
2221.11.1 by Olaf van der Spek
Session::getLex()
1055
   *
1055.2.24 by Jay Pipes
Merge with trunk and resolve conflicts.
1056
   * The lock will automaticaly be freed by close_thread_tables()
1057
   */
2263.3.5 by Olaf van der Spek
Refactor Open_tables_state
1058
  bool openTablesLock(TableList*);
1059
  Table *open_temporary_table(const identifier::Table &identifier, bool link_in_list= true);
1109.1.2 by Brian Aker
More from the table patch
1060
1061
  int open_tables_from_list(TableList **start, uint32_t *counter, uint32_t flags= 0);
1109.1.3 by Brian Aker
Move names around a bit (to align similar methods)
1062
1063
  Table *openTableLock(TableList *table_list, thr_lock_type lock_type);
1064
  Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1065
1054.1.11 by Brian Aker
Remove dead lock.cc commands.
1066
  void unlink_open_table(Table *find);
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
1067
  void drop_open_table(Table *table, const identifier::Table &identifier);
1054.1.11 by Brian Aker
Remove dead lock.cc commands.
1068
  void close_cached_table(Table *table);
1054.1.9 by Brian Aker
This is a large number of refactors against the Session class for its
1069
1070
  /* Create a lock in the cache */
2263.3.13 by Olaf van der Spek
Table Cache
1071
  table::Placeholder& table_cache_insert_placeholder(const identifier::Table&);
2263.9.1 by Olaf van der Spek
Table Cache
1072
  Table* lock_table_name_if_not_cached(const identifier::Table&);
1054.1.9 by Brian Aker
This is a large number of refactors against the Session class for its
1073
2239.1.8 by Olaf van der Spek
Refactor includes
1074
  session::TableMessages &getMessageCache();
1358.1.2 by Brian Aker
Long pass through the system to use more of TableIdentifiers.
1075
1054.1.9 by Brian Aker
This is a large number of refactors against the Session class for its
1076
  /* Reopen operations */
2085.2.1 by Brian Aker
Fix in style/scope issue/removed dead options to method.
1077
  bool reopen_tables();
1109.1.4 by Brian Aker
More Table refactor
1078
  bool close_cached_tables(TableList *tables, bool wait_for_refresh, bool wait_for_placeholders);
1054.1.10 by Brian Aker
Move open_table() to session.
1079
1812.3.5 by Brian Aker
Move to boost condition_any
1080
  void wait_for_condition(boost::mutex &mutex, boost::condition_variable_any &cond);
1109.1.5 by Brian Aker
More extraction from sql_base
1081
  int setup_conds(TableList *leaves, COND **conds);
1082
  int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1183.1.1 by Brian Aker
Rework interface pieces on SE (sort of... dumb ones...)
1083
2240.5.12 by Olaf van der Spek
Refactor
1084
  template <class T>
1085
  T* getProperty(const std::string& name)
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1086
  {
2240.5.12 by Olaf van der Spek
Refactor
1087
    return static_cast<T*>(getProperty0(name));
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1088
  }
1089
2240.5.12 by Olaf van der Spek
Refactor
1090
  template <class T>
1091
  T setProperty(const std::string& name, T value)
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1092
  {
2240.5.12 by Olaf van der Spek
Refactor
1093
    setProperty0(name, value);
2240.5.1 by Olaf van der Spek
Session::getProperty
1094
    return value;
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1095
  }
1183.1.1 by Brian Aker
Rework interface pieces on SE (sort of... dumb ones...)
1096
1097
  /**
1098
    Return the default storage engine
1099
1100
    @param getDefaultStorageEngine()
1101
1102
    @return
1103
    pointer to plugin::StorageEngine
1104
  */
2239.1.9 by Olaf van der Spek
Refactor includes
1105
  plugin::StorageEngine *getDefaultStorageEngine();
2385.3.6 by Olaf van der Spek
cppcheck
1106
  void get_xid(DrizzleXid *xid) const; // Innodb only
1532.1.1 by Brian Aker
Merge of change to flip table instance to be share instance
1107
2241.3.6 by Olaf van der Spek
Refactor
1108
  table::Singular& getInstanceTable();
1109
  table::Singular& getInstanceTable(std::list<CreateField>&);
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1110
1111
  void setUsage(bool arg)
1112
  {
1113
    use_usage= arg;
1114
  }
1115
2227.4.11 by Olaf van der Spek
Refactor Session
1116
  const rusage &getUsage()
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1117
  {
1118
    return usage;
1119
  }
1120
2241.3.14 by Olaf van der Spek
Refactor
1121
  const catalog::Instance& catalog() const
2060.4.2 by Brian Aker
A few small fixes, plus move the schema lock to the actual catalog.
1122
  {
2227.4.11 by Olaf van der Spek
Refactor Session
1123
    return *_catalog;
2060.4.2 by Brian Aker
A few small fixes, plus move the schema lock to the actual catalog.
1124
  }
1125
2241.3.14 by Olaf van der Spek
Refactor
1126
  catalog::Instance& catalog()
2060.4.2 by Brian Aker
A few small fixes, plus move the schema lock to the actual catalog.
1127
  {
2227.4.11 by Olaf van der Spek
Refactor Session
1128
    return *_catalog;
2039.6.4 by Brian Aker
Merge in local_instance change.
1129
  }
1130
2227.4.12 by Olaf van der Spek
Refactor Session
1131
  bool arg_of_last_insert_id_function; // Tells if LAST_INSERT_ID(#) was called for the current statement
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1132
private:
2240.5.3 by Olaf van der Spek
Session::properties
1133
  drizzled::util::Storable* getProperty0(const std::string&);
1134
  void setProperty0(const std::string&, drizzled::util::Storable*);
1135
2227.4.11 by Olaf van der Spek
Refactor Session
1136
  bool resetUsage()
1137
  {
1138
    return not getrusage(RUSAGE_THREAD, &usage);
1139
  }
1140
2241.3.14 by Olaf van der Spek
Refactor
1141
  boost::shared_ptr<catalog::Instance> _catalog;
2039.6.3 by Brian Aker
Update for session to have a catalog object.
1142
2227.4.13 by Olaf van der Spek
Refactor Session
1143
  /** Pointers to memory managed by the ReplicationServices component */
1144
  message::Transaction *transaction_message;
1145
  message::Statement *statement_message;
1146
  /* Pointer to the current resultset of Select query */
1147
  message::Resultset *resultset;
1148
  plugin::EventObserverList *session_event_observers;
1149
2227.4.12 by Olaf van der Spek
Refactor Session
1150
  uint64_t xa_id;
1151
  const char *proc_info;
1152
  bool abort_on_warning;
1153
  bool concurrent_execute_allowed;
1154
  bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
1764.3.6 by Brian Aker
This includes a query_usage table for looking at performance of previous
1155
  bool use_usage;
2227.4.11 by Olaf van der Spek
Refactor Session
1156
  rusage usage;
2252.1.8 by Olaf van der Spek
Common fwd
1157
  identifier::user::mptr security_ctx;
2241.2.4 by Olaf van der Spek
Refactor
1158
  int32_t scoreboard_index;
2290.1.2 by Joseph Daly
server uuid as part of replication table
1159
  bool originating_server_uuid_set;
1160
  std::string originating_server_uuid;
1161
  uint64_t originating_commit_id;
2241.2.4 by Olaf van der Spek
Refactor
1162
  plugin::Client *client;
1 by brian
clean slate
1163
};
1164
1165
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
1166
1167
/* Bits in sql_command_flags */
1168
2221.11.1 by Olaf van der Spek
Session::getLex()
1169
enum sql_command_flag_bits
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.
1170
{
590.2.17 by Monty Taylor
Changed CF_BIT_* to an enum.
1171
  CF_BIT_CHANGES_DATA,
1172
  CF_BIT_HAS_ROW_COUNT,
1173
  CF_BIT_STATUS_COMMAND,
1174
  CF_BIT_SHOW_TABLE_COMMAND,
590.2.18 by Monty Taylor
Changed the bitset<32> to a bitset<5>. Made the int constants into bitset constants.
1175
  CF_BIT_WRITE_LOGS_COMMAND,
1176
  CF_BIT_SIZE
590.2.17 by Monty Taylor
Changed CF_BIT_* to an enum.
1177
};
602.2.2 by Yoshinori Sano
Fix bugs in params of sql_command_flags[...].test(). Previously, the value such as, 0, 1, 2, 4, 8 and 16 is given to std::bitset.test() in that place, which is misunderstanding of the spec of the test(). The test(size_t n) returns true if bit n is set.
1178
590.2.18 by Monty Taylor
Changed the bitset<32> to a bitset<5>. Made the int constants into bitset constants.
1179
static const std::bitset<CF_BIT_SIZE> CF_CHANGES_DATA(1 << CF_BIT_CHANGES_DATA);
1180
static const std::bitset<CF_BIT_SIZE> CF_HAS_ROW_COUNT(1 << CF_BIT_HAS_ROW_COUNT);
1181
static const std::bitset<CF_BIT_SIZE> CF_STATUS_COMMAND(1 << CF_BIT_STATUS_COMMAND);
1182
static const std::bitset<CF_BIT_SIZE> CF_SHOW_TABLE_COMMAND(1 << CF_BIT_SHOW_TABLE_COMMAND);
1183
static const std::bitset<CF_BIT_SIZE> CF_WRITE_LOGS_COMMAND(1 << CF_BIT_WRITE_LOGS_COMMAND);
1 by brian
clean slate
1184
2241.2.4 by Olaf van der Spek
Refactor
1185
namespace display  
1186
{
1187
  const std::string &type(Session::global_read_lock_t);
1188
  size_t max_string_length(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
1189
} /* namespace display */
1190
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1191
} /* namespace drizzled */
1192