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