17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_SESSION_H
22
#define DRIZZLED_SESSION_H
24
#include "drizzled/plugin.h"
25
#include "drizzled/sql_locale.h"
26
#include "drizzled/resource_context.h"
27
#include "drizzled/cursor.h"
28
#include "drizzled/current_session.h"
29
#include "drizzled/sql_error.h"
30
#include "drizzled/file_exchange.h"
31
#include "drizzled/select_result_interceptor.h"
32
#include "drizzled/statistics_variables.h"
33
#include "drizzled/xid.h"
34
#include "drizzled/query_id.h"
35
#include "drizzled/named_savepoint.h"
36
#include "drizzled/transaction_context.h"
37
#include "drizzled/util/storable.h"
38
#include "drizzled/my_hash.h"
39
#include "drizzled/pthread_globals.h"
42
#include <sys/resource.h>
22
44
#include <algorithm>
24
#include <boost/make_shared.hpp>
25
#include <boost/scoped_ptr.hpp>
26
#include <boost/thread/condition_variable.hpp>
50
#include "drizzled/identifier.h"
51
#include "drizzled/open_tables_state.h"
52
#include "drizzled/internal_error_handler.h"
53
#include "drizzled/diagnostics_area.h"
54
#include "drizzled/plugin/authorization.h"
56
#include <boost/unordered_map.hpp>
58
#include <boost/thread/thread.hpp>
27
59
#include <boost/thread/mutex.hpp>
28
60
#include <boost/thread/shared_mutex.hpp>
29
#include <boost/thread/thread.hpp>
33
#include <sys/resource.h>
36
#include <drizzled/charset.h>
37
#include <drizzled/base.h>
38
#include <drizzled/error.h>
39
#include <drizzled/lock.h>
40
#include <drizzled/pthread_globals.h>
41
#include <drizzled/sql_error.h>
42
#include <drizzled/sql_locale.h>
43
#include <drizzled/visibility.h>
44
#include <drizzled/util/find_ptr.h>
45
#include <drizzled/util/string.h>
46
#include <drizzled/type/time.h>
50
extern uint32_t server_id;
51
extern std::string server_uuid;
61
#include <boost/thread/condition_variable.hpp>
62
#include <boost/make_shared.hpp>
65
#define MIN_HANDSHAKE_SIZE 6
74
class EventObserverList;
86
struct st_my_thread_var;
94
class Lex_input_stream;
99
class TableShareInstance;
101
extern char internal_table_name[2];
102
extern char empty_c_string[1];
103
extern const char **errmesg;
53
105
#define TC_HEURISTIC_RECOVER_COMMIT 1
54
106
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
55
107
extern uint32_t tc_heuristic_recover;
57
extern DRIZZLED_API struct drizzle_system_variables global_system_variables;
111
Local storage for proto that are tmp table. This should be enlarged
112
to hande the entire table-share for a local table. Once Hash is done,
113
we should consider exchanging the map for it.
115
typedef std::map <std::string, message::Table> ProtoCache;
118
The COPY_INFO structure is used by INSERT/REPLACE code.
119
The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY
121
If a row is inserted then the copied variable is incremented.
122
If a row is updated by the INSERT ... ON DUPLICATE KEY UPDATE and the
123
new data differs from the old one then the copied and the updated
124
variables are incremented.
125
The touched variable is incremented if a row was touched by the update part
126
of the INSERT ... ON DUPLICATE KEY UPDATE no matter whether the row
127
was actually changed or not.
132
ha_rows records; /**< Number of processed records */
133
ha_rows deleted; /**< Number of deleted records */
134
ha_rows updated; /**< Number of updated records */
135
ha_rows copied; /**< Number of copied records */
137
ha_rows touched; /* Number of touched records */
138
enum enum_duplicates handle_duplicates;
139
int escape_char, last_errno;
141
/* for INSERT ... UPDATE */
142
List<Item> *update_fields;
143
List<Item> *update_values;
144
/* for VIEW ... WITH CHECK OPTION */
162
} /* namespace drizzled */
164
/** @TODO why is this in the middle of the file */
165
#include <drizzled/lex_column.h>
173
#define Session_SENTRY_MAGIC 0xfeedd1ff
174
#define Session_SENTRY_GONE 0xdeadbeef
176
struct drizzle_system_variables
178
drizzle_system_variables()
181
How dynamically allocated system variables are handled:
183
The global_system_variables and max_system_variables are "authoritative"
184
They both should have the same 'version' and 'size'.
185
When attempting to access a dynamic variable, if the session version
186
is out of date, then the session version is updated and realloced if
187
neccessary and bytes copied from global to make up for missing data.
189
ulong dynamic_variables_version;
190
char * dynamic_variables_ptr;
191
uint32_t dynamic_variables_head; /* largest valid variable offset */
192
uint32_t dynamic_variables_size; /* how many bytes are in use */
194
uint64_t myisam_max_extra_sort_file_size;
195
uint64_t max_heap_table_size;
196
uint64_t tmp_table_size;
197
ha_rows select_limit;
198
ha_rows max_join_size;
199
uint64_t auto_increment_increment;
200
uint64_t auto_increment_offset;
201
uint64_t bulk_insert_buff_size;
202
uint64_t join_buff_size;
203
uint32_t max_allowed_packet;
204
uint64_t max_error_count;
205
uint64_t max_length_for_sort_data;
206
size_t max_sort_length;
207
uint64_t min_examined_row_limit;
208
bool optimizer_prune_level;
211
uint32_t optimizer_search_depth;
212
uint32_t div_precincrement;
213
uint64_t preload_buff_size;
214
uint32_t read_buff_size;
215
uint32_t read_rnd_buff_size;
216
bool replicate_query;
217
size_t sortbuff_size;
218
uint32_t thread_handling;
219
uint32_t tx_isolation;
220
size_t transaction_message_threshold;
221
uint32_t completion_type;
222
/* Determines which non-standard SQL behaviour should be enabled */
224
uint64_t max_seeks_for_key;
225
size_t range_alloc_block_size;
226
uint32_t query_alloc_block_size;
227
uint32_t query_prealloc_size;
228
uint64_t group_concat_max_len;
229
uint64_t pseudo_thread_id;
231
plugin::StorageEngine *storage_engine;
233
/* Only charset part of these variables is sensible */
234
const CHARSET_INFO *character_set_filesystem;
236
/* Both charset and collation parts of these variables are important */
237
const CHARSET_INFO *collation_server;
239
inline const CHARSET_INFO *getCollation(void)
241
return collation_server;
245
MY_LOCALE *lc_time_names;
247
Time_zone *time_zone;
250
extern struct drizzle_system_variables global_system_variables;
252
} /* namespace drizzled */
254
#include "drizzled/sql_lex.h"
259
void mark_transaction_to_rollback(Session *session, bool all);
262
Storage engine specific thread local data.
267
Storage engine specific thread local data.
268
Lifetime: one user connection.
272
* Resource contexts for both the "statement" and "normal"
275
* Resource context at index 0:
277
* Life time: one statement within a transaction. If @@autocommit is
278
* on, also represents the entire transaction.
280
* Resource context at index 1:
282
* Life time: one transaction within a connection.
286
* If the storage engine does not participate in a transaction,
287
* there will not be a resource context.
289
drizzled::ResourceContext resource_context[2];
291
Ha_data() :ha_ptr(NULL) {}
60
295
* Represents a client connection to the database server.
104
331
that it needs to update this field in write_row
107
enum_mark_columns mark_used_columns;
334
enum enum_mark_columns mark_used_columns;
335
inline void* alloc(size_t size)
337
return mem_root->alloc_root(size);
339
inline void* calloc(size_t size)
342
if ((ptr= mem_root->alloc_root(size)))
343
memset(ptr, 0, size);
346
inline char *strdup(const char *str)
348
return mem_root->strdup_root(str);
350
inline char *strmake(const char *str, size_t size)
352
return mem_root->strmake_root(str,size);
354
inline void *memdup(const void *str, size_t size)
356
return mem_root->memdup_root(str, size);
358
inline void *memdup_w_gap(const void *str, size_t size, uint32_t gap)
361
if ((ptr= mem_root->alloc_root(size + gap)))
362
memcpy(ptr,str,size);
109
365
/** Frees all items attached to this Statement */
110
366
void free_items();
113
368
* List of items created in the parser for this query. Every item puts
114
369
* itself to the list on creation (see Item::Item() for details))
118
memory::Root* mem_root; /**< Pointer to current memroot */
120
uint64_t getXaId() const
372
memory::Root *mem_root; /**< Pointer to current memroot */
375
memory::Root *getMemRoot()
125
387
void setXaId(uint64_t in_xa_id)
131
Diagnostics_area& main_da();
132
const LEX& lex() const;
134
enum_sql_command getSqlCommand() const;
393
* Uniquely identifies each statement object in thread scope; change during
394
* statement lifetime.
396
* @todo should be const
399
LEX *lex; /**< parse tree descriptor */
136
405
/** query associated with this statement */
137
406
typedef boost::shared_ptr<const std::string> QueryString;
140
408
boost::shared_ptr<std::string> query;
143
411
// requires under some setup non const, you must copy the QueryString in
144
412
// order to use it.
146
void resetQueryString();
147
const boost::shared_ptr<session::State>& state();
149
414
QueryString getQueryString() const
154
const char* getQueryStringCopy(size_t &length)
419
void resetQueryString()
426
We need to copy the lock on the string in order to make sure we have a stable string.
427
Once this is done we can use it to build a const char* which can be handed off for
428
a method to use (Innodb is currently the only engine using this).
430
const char *getQueryStringCopy(size_t &length)
156
432
QueryString tmp_string(getQueryString());
157
434
if (not tmp_string)
162
440
length= tmp_string->length();
163
return mem.strdup(*tmp_string);
166
util::string::ptr schema() const;
441
char *to_return= strmake(tmp_string->c_str(), tmp_string->length());
446
std::vector <char> _query;
449
typedef boost::shared_ptr<State> const_shared_ptr;
451
State(const char *in_packet, size_t in_packet_length)
453
if (in_packet_length)
455
size_t minimum= std::min(in_packet_length, static_cast<size_t>(PROCESS_LIST_WIDTH));
456
_query.resize(minimum + 1);
457
memcpy(&_query[0], in_packet, minimum);
465
const char *query() const
473
const char *query(size_t &size) const
477
size= _query.size() -1;
485
friend class Session;
486
typedef boost::shared_ptr<State> shared_ptr;
489
State::shared_ptr _state;
492
State::const_shared_ptr state()
498
Name of the current (default) database.
500
If there is the current (default) database, "db" contains its name. If
501
there is no current (default) database, "db" is NULL and "db_length" is
502
0. In other words, "db", "db_length" must either be NULL, or contain a
505
@note this attribute is set and alloced by the slave SQL thread (for
506
the Session of that thread); that thread is (and must remain, for now) the
507
only responsible for freeing this member.
510
util::string::shared_ptr _schema;
513
util::string::const_shared_ptr schema() const
518
return util::string::const_shared_ptr(new std::string(""));
521
/* current cache key */
522
std::string query_cache_key;
169
524
Constant for Session::where initialization in the beginning of every query.
171
526
It's needed because we do not save/restore Session::where normally during
172
527
primary (non subselect) query execution.
174
static const char* const DEFAULT_WHERE;
529
static const char * const DEFAULT_WHERE;
176
531
memory::Root warn_root; /**< Allocation area for warnings and errors */
532
plugin::Client *client; /**< Pointer to client object */
178
534
void setClient(plugin::Client *client_arg);
180
plugin::Client *getClient() const
536
plugin::Client *getClient()
185
plugin::Scheduler* scheduler; /**< Pointer to scheduler object */
187
typedef boost::unordered_map<std::string, user_var_entry*, util::insensitive_hash, util::insensitive_equal_to> UserVars;
541
plugin::Scheduler *scheduler; /**< Pointer to scheduler object */
542
void *scheduler_arg; /**< Pointer to the optional scheduler argument */
544
typedef boost::unordered_map< std::string, user_var_entry *, util::insensitive_hash, util::insensitive_equal_to> UserVars;
190
546
typedef std::pair< UserVars::iterator, UserVars::iterator > UserVarsRange;
191
547
UserVars user_vars; /**< Hash of user variables defined during the session's lifetime */
194
551
const UserVars &getUserVariables() const
196
553
return user_vars;
199
drizzle_system_variables& variables; /**< Mutable local variables local to the session */
200
enum_tx_isolation getTxIsolation() const;
201
system_status_var& status_var;
556
drizzle_system_variables variables; /**< Mutable local variables local to the session */
557
struct system_status_var status_var; /**< Session-local status counters */
203
558
THR_LOCK_INFO lock_info; /**< Locking information for this session */
204
559
THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
205
560
THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
230
598
scoreboard_index= in_scoreboard_index;
233
bool isOriginatingServerUUIDSet() const
235
return originating_server_uuid_set;
238
void setOriginatingServerUUID(std::string in_originating_server_uuid)
240
originating_server_uuid= in_originating_server_uuid;
241
originating_server_uuid_set= true;
244
const std::string &getOriginatingServerUUID() const
246
return originating_server_uuid;
249
void setOriginatingCommitID(uint64_t in_originating_commit_id)
251
originating_commit_id= in_originating_commit_id;
254
uint64_t getOriginatingCommitID() const
256
return originating_commit_id;
260
602
* Is this session viewable by the current user?
262
bool isViewable(const identifier::User&) const;
604
bool isViewable() const;
266
607
Used in error messages to tell user in what part of MySQL we found an
267
608
error. E. g. when where= "having clause", if fix_fields() fails, user
268
609
will know that the error was in having clause.
273
const char *where() const
278
void setWhere(const char *arg)
284
614
One thread can hold up to one named user-level lock. This variable
285
615
points to a lock object if the lock is present. See item_func.cc and
286
616
chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK.
618
uint32_t dbug_sentry; /**< watch for memory corruption */
290
620
boost::thread::id boost_thread_id;
621
boost_thread_shared_ptr _thread;
292
622
boost::this_thread::disable_interruption *interrupt;
294
624
internal::st_my_thread_var *mysys_var;
297
thread_ptr &getThread()
627
boost_thread_shared_ptr &getThread()
813
1227
const char* enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg);
814
1228
void exit_cond(const char* old_msg);
816
uint64_t found_rows() const
1230
inline time_t query_start() { return start_time; }
1231
inline void set_time()
1233
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1234
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1235
start_utime= utime_after_lock= (mytime-epoch).total_microseconds();
1239
start_time= user_time;
1240
connect_microseconds= start_utime;
1243
start_time= (mytime-epoch).total_seconds();
1245
inline void set_current_time() { start_time= time(NULL); }
1246
inline void set_time(time_t t)
1248
start_time= user_time= t;
1249
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1250
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1251
uint64_t t_mark= (mytime-epoch).total_microseconds();
1253
start_utime= utime_after_lock= t_mark;
1255
void set_time_after_lock() {
1256
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1257
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1258
utime_after_lock= (mytime-epoch).total_microseconds();
1261
* Returns the current micro-timestamp
1263
inline uint64_t getCurrentTimestamp()
1265
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1266
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1267
uint64_t t_mark= (mytime-epoch).total_microseconds();
1271
inline uint64_t found_rows(void)
818
1273
return limit_found_rows;
821
1275
/** Returns whether the session is currently inside a transaction */
822
bool inTransaction() const
1276
inline bool inTransaction()
824
1278
return server_status & SERVER_STATUS_IN_TRANS;
827
lex_string_t* make_lex_string(lex_string_t*, str_ref);
829
void send_explain_fields(select_result*);
831
void clear_error(bool full= false);
832
void clearDiagnostics();
833
bool is_error() const;
835
static const charset_info_st *charset() { return default_charset_info; }
1280
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1281
const char* str, uint32_t length,
1282
bool allocate_lex_string);
1283
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1284
const std::string &str,
1285
bool allocate_lex_string);
1287
int send_explain_fields(select_result *result);
1289
Clear the current error, if any.
1290
We do not clear is_fatal_error or is_fatal_sub_stmt_error since we
1291
assume this is never called if the fatal error is set.
1292
@todo: To silence an error, one should use Internal_error_handler
1293
mechanism. In future this function will be removed.
1295
inline void clear_error(bool full= false)
1297
if (main_da.is_error())
1298
main_da.reset_diagnostics_area();
1302
drizzle_reset_errors(this, true);
1306
void clearDiagnostics()
1308
main_da.reset_diagnostics_area();
1312
Mark the current error as fatal. Warning: this does not
1313
set any error, it sets a property of the error, so must be
1314
followed or prefixed with my_error().
1316
inline void fatal_error()
1318
assert(main_da.is_error());
1319
is_fatal_error= true;
1322
true if there is an error in the error stack.
1324
Please use this method instead of direct access to
1327
If true, the current (sub)-statement should be aborted.
1328
The main difference between this member and is_fatal_error
1329
is that a fatal error can not be handled by a stored
1330
procedure continue handler, whereas a normal error can.
1332
To raise this flag, use my_error().
1334
inline bool is_error() const { return main_da.is_error(); }
1335
inline const CHARSET_INFO *charset() { return default_charset_info; }
1337
void change_item_tree(Item **place, Item *new_value)
838
1342
Cleanup statement parse state (parse tree, lex) and execution
839
1343
state after execution of a non-prepared SQL statement.
997
1526
void resetResultsetMessage()
999
1528
resultset= NULL;
1002
plugin::EventObserverList *getSessionObservers()
1532
/** Pointers to memory managed by the ReplicationServices component */
1533
message::Transaction *transaction_message;
1534
message::Statement *statement_message;
1535
/* Pointer to the current resultset of Select query */
1536
message::Resultset *resultset;
1537
plugin::EventObserverList *session_event_observers;
1539
/* Schema observers are mapped to databases. */
1540
std::map<std::string, plugin::EventObserverList *> schema_event_observers;
1544
plugin::EventObserverList *getSessionObservers()
1004
1546
return session_event_observers;
1007
void setSessionObservers(plugin::EventObserverList *observers)
1549
void setSessionObservers(plugin::EventObserverList *observers)
1009
1551
session_event_observers= observers;
1012
plugin::EventObserverList* getSchemaObservers(const std::string& schema);
1013
plugin::EventObserverList* setSchemaObservers(const std::string& schema, plugin::EventObserverList*);
1554
/* For schema event observers there is one set of observers per database. */
1555
plugin::EventObserverList *getSchemaObservers(const std::string &db_name)
1557
std::map<std::string, plugin::EventObserverList *>::iterator it;
1559
it= schema_event_observers.find(db_name);
1560
if (it == schema_event_observers.end())
1566
void setSchemaObservers(const std::string &db_name, plugin::EventObserverList *observers)
1568
std::map<std::string, plugin::EventObserverList *>::iterator it;
1570
it= schema_event_observers.find(db_name);
1571
if (it != schema_event_observers.end())
1572
schema_event_observers.erase(it);;
1575
schema_event_observers[db_name] = observers;
1580
/** Microsecond timestamp of when Session connected */
1581
uint64_t connect_microseconds;
1582
const char *proc_info;
1584
/** The current internal error handler for this thread, or NULL. */
1585
Internal_error_handler *m_internal_handler;
1587
The lex to hold the parsed tree of conventional (non-prepared) queries.
1588
Whereas for prepared and stored procedure statements we use an own lex
1589
instance for each new query, for conventional statements we reuse
1590
the same lex. (@see mysql_parse for details).
1594
This memory root is used for two purposes:
1595
- for conventional queries, to allocate structures stored in main_lex
1596
during parsing, and allocate runtime data (execution plan, etc.)
1598
- for prepared queries, only to allocate runtime data. The parsed
1599
tree itself is reused between executions and thus is stored elsewhere.
1601
memory::Root main_mem_root;
1604
* Marks all tables in the list which were used by current substatement
1605
* as free for reuse.
1607
* @param Head of the list of tables
1611
* The reason we reset query_id is that it's not enough to just test
1612
* if table->query_id != session->query_id to know if a table is in use.
1616
* SELECT f1_that_uses_t1() FROM t1;
1618
* In f1_that_uses_t1() we will see one instance of t1 where query_id is
1619
* set to query_id of original query.
1621
void mark_used_tables_as_free_for_reuse(Table *table);
1016
void my_ok(ha_rows affected_rows= 0, ha_rows found_rows_arg= 0, uint64_t passed_id= 0, const char *message= NULL);
1018
void add_item_to_list(Item *item);
1019
void add_value_to_list(Item *value);
1020
void add_order_to_list(Item *item, bool asc);
1021
void add_group_to_list(Item *item, bool asc);
1625
/** A short cut for session->main_da.set_ok_status(). */
1626
inline void my_ok(ha_rows affected_rows= 0, ha_rows found_rows_arg= 0,
1627
uint64_t passed_id= 0, const char *message= NULL)
1629
main_da.set_ok_status(this, affected_rows, found_rows_arg, passed_id, message);
1633
/** A short cut for session->main_da.set_eof_status(). */
1635
inline void my_eof()
1637
main_da.set_eof_status(this);
1640
/* Some inline functions for more speed */
1642
inline bool add_item_to_list(Item *item)
1644
return lex->current_select->add_item_to_list(this, item);
1647
inline bool add_value_to_list(Item *value)
1649
return lex->value_list.push_back(value);
1652
inline bool add_order_to_list(Item *item, bool asc)
1654
return lex->current_select->add_order_to_list(this, item, asc);
1657
inline bool add_group_to_list(Item *item, bool asc)
1659
return lex->current_select->add_group_to_list(this, item, asc);
1023
1661
void refresh_status();
1024
user_var_entry *getVariable(lex_string_t &name, bool create_if_not_exists);
1662
user_var_entry *getVariable(LEX_STRING &name, bool create_if_not_exists);
1025
1663
user_var_entry *getVariable(const std::string &name, bool create_if_not_exists);
1026
1664
void setVariable(const std::string &name, const std::string &value);
1029
1667
* Closes all tables used by the current substatement, or all tables
1030
1668
* used by this thread if we are on the upper level.
1066
1708
Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1068
1710
void unlink_open_table(Table *find);
1069
void drop_open_table(Table *table, const identifier::Table &identifier);
1711
void drop_open_table(Table *table, const TableIdentifier &identifier);
1070
1712
void close_cached_table(Table *table);
1072
1714
/* Create a lock in the cache */
1073
table::Placeholder& table_cache_insert_placeholder(const identifier::Table&);
1074
Table* lock_table_name_if_not_cached(const identifier::Table&);
1076
session::TableMessages &getMessageCache();
1715
table::Placeholder *table_cache_insert_placeholder(const TableIdentifier &identifier);
1716
bool lock_table_name_if_not_cached(const TableIdentifier &identifier, Table **table);
1718
typedef boost::unordered_map<std::string, message::Table, util::insensitive_hash, util::insensitive_equal_to> TableMessageCache;
1722
TableMessageCache table_message_cache;
1725
bool storeTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1726
bool removeTableMessage(const TableIdentifier &identifier);
1727
bool getTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1728
bool doesTableMessageExist(const TableIdentifier &identifier);
1729
bool renameTableMessage(const TableIdentifier &from, const TableIdentifier &to);
1733
TableMessages _table_message_cache;
1736
TableMessages &getMessageCache()
1738
return _table_message_cache;
1078
1741
/* Reopen operations */
1079
bool reopen_tables();
1742
bool reopen_tables(bool get_locks, bool mark_share_as_old);
1080
1743
bool close_cached_tables(TableList *tables, bool wait_for_refresh, bool wait_for_placeholders);
1082
1745
void wait_for_condition(boost::mutex &mutex, boost::condition_variable_any &cond);
1083
1746
int setup_conds(TableList *leaves, COND **conds);
1084
1747
int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1087
T* getProperty(const std::string& name)
1749
drizzled::util::Storable *getProperty(const std::string &arg)
1089
return static_cast<T*>(getProperty0(name));
1751
return life_properties[arg];
1093
T setProperty(const std::string& name, T value)
1755
bool setProperty(const std::string &arg, T *value)
1095
setProperty0(name, value);
1757
life_properties[arg]= value;
1105
1768
pointer to plugin::StorageEngine
1107
plugin::StorageEngine *getDefaultStorageEngine();
1108
void get_xid(DrizzleXid *xid) const; // Innodb only
1110
table::Singular& getInstanceTable();
1111
table::Singular& getInstanceTable(std::list<CreateField>&);
1770
plugin::StorageEngine *getDefaultStorageEngine()
1772
if (variables.storage_engine)
1773
return variables.storage_engine;
1774
return global_system_variables.storage_engine;
1777
void get_xid(DRIZZLE_XID *xid); // Innodb only
1779
table::Instance *getInstanceTable();
1780
table::Instance *getInstanceTable(List<CreateField> &field_list);
1785
if (getrusage(RUSAGE_THREAD, &usage))
1113
1794
void setUsage(bool arg)
1115
1796
use_usage= arg;
1118
const rusage &getUsage()
1799
const struct rusage &getUsage()
1123
const catalog::Instance& catalog() const
1128
catalog::Instance& catalog()
1133
bool arg_of_last_insert_id_function; // Tells if LAST_INSERT_ID(#) was called for the current statement
1135
drizzled::util::Storable* getProperty0(const std::string&);
1136
void setProperty0(const std::string&, drizzled::util::Storable*);
1140
return not getrusage(RUSAGE_THREAD, &usage);
1143
boost::shared_ptr<catalog::Instance> _catalog;
1145
/** Pointers to memory managed by the ReplicationServices component */
1146
message::Transaction *transaction_message;
1147
message::Statement *statement_message;
1148
/* Pointer to the current resultset of Select query */
1149
message::Resultset *resultset;
1150
plugin::EventObserverList *session_event_observers;
1153
const char *proc_info;
1154
bool abort_on_warning;
1155
bool concurrent_execute_allowed;
1156
bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
1805
// This lives throughout the life of Session
1157
1806
bool use_usage;
1159
identifier::user::mptr security_ctx;
1160
int32_t scoreboard_index;
1161
bool originating_server_uuid_set;
1162
std::string originating_server_uuid;
1163
uint64_t originating_commit_id;
1164
plugin::Client *client;
1807
PropertyMap life_properties;
1808
std::vector<table::Instance *> temporary_shares;
1809
struct rusage usage;
1167
1814
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
1816
} /* namespace drizzled */
1818
/** @TODO why is this in the middle of the file */
1819
#include <drizzled/select_to_file.h>
1820
#include <drizzled/select_export.h>
1821
#include <drizzled/select_dump.h>
1822
#include <drizzled/select_insert.h>
1823
#include <drizzled/select_create.h>
1824
#include <drizzled/tmp_table_param.h>
1825
#include <drizzled/select_union.h>
1826
#include <drizzled/select_subselect.h>
1827
#include <drizzled/select_singlerow_subselect.h>
1828
#include <drizzled/select_max_min_finder_subselect.h>
1829
#include <drizzled/select_exists_subselect.h>
1835
* A structure used to describe sort information
1836
* for a field or item used in ORDER BY.
1841
Field *field; /**< Field to sort */
1842
Item *item; /**< Item if not sorting fields */
1843
size_t length; /**< Length of sort field */
1844
uint32_t suffix_length; /**< Length suffix (0-4) */
1845
Item_result result_type; /**< Type of item */
1846
bool reverse; /**< if descending sort */
1847
bool need_strxnfrm; /**< If we have to use strxnfrm() */
1854
result_type(STRING_RESULT),
1861
} /* namespace drizzled */
1863
/** @TODO why is this in the middle of the file */
1865
#include <drizzled/table_ident.h>
1866
#include <drizzled/user_var_entry.h>
1867
#include <drizzled/unique.h>
1868
#include <drizzled/var.h>
1869
#include <drizzled/select_dumpvar.h>
1169
1874
/* Bits in sql_command_flags */
1171
enum sql_command_flag_bits
1876
enum sql_command_flag_bits
1173
1878
CF_BIT_CHANGES_DATA,
1174
1879
CF_BIT_HAS_ROW_COUNT,