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