17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
21
#ifndef DRIZZLED_SESSION_H
21
22
#define DRIZZLED_SESSION_H
25
#include <boost/make_shared.hpp>
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>
24
/* Classes in mysql */
26
#include "drizzled/plugin.h"
27
#include <drizzled/sql_locale.h>
28
#include "drizzled/resource_context.h"
29
#include <drizzled/cursor.h>
30
#include <drizzled/current_session.h>
31
#include <drizzled/sql_error.h>
32
#include <drizzled/file_exchange.h>
33
#include <drizzled/select_result_interceptor.h>
34
#include <drizzled/xid.h>
35
#include "drizzled/query_id.h"
36
#include "drizzled/named_savepoint.h"
37
#include "drizzled/transaction_context.h"
33
#include <sys/resource.h>
36
#include <drizzled/catalog/instance.h>
37
#include <drizzled/catalog/local.h>
38
#include <drizzled/copy_info.h>
39
#include <drizzled/cursor.h>
45
#include <drizzled/security_context.h>
46
#include <drizzled/open_tables_state.h>
48
#include <drizzled/internal_error_handler.h>
40
49
#include <drizzled/diagnostics_area.h>
41
#include <drizzled/file_exchange.h>
42
#include <drizzled/ha_data.h>
43
#include <drizzled/identifier.h>
44
#include <drizzled/lex_column.h>
45
#include <drizzled/my_hash.h>
46
#include <drizzled/named_savepoint.h>
47
#include <drizzled/open_tables_state.h>
48
#include <drizzled/plugin.h>
49
51
#include <drizzled/plugin/authorization.h>
50
#include <drizzled/pthread_globals.h>
51
#include <drizzled/query_id.h>
52
#include <drizzled/resource_context.h>
53
#include <drizzled/session/property_map.h>
54
#include <drizzled/session/state.h>
55
#include <drizzled/session/table_messages.h>
56
#include <drizzled/session/transactions.h>
57
#include <drizzled/sql_error.h>
58
#include <drizzled/sql_lex.h>
59
#include <drizzled/sql_locale.h>
60
#include <drizzled/statistics_variables.h>
61
#include <drizzled/system_variables.h>
62
#include <drizzled/system_variables.h>
63
#include <drizzled/table_ident.h>
64
#include <drizzled/transaction_context.h>
65
#include <drizzled/util/storable.h>
66
#include <drizzled/var.h>
67
#include <drizzled/visibility.h>
69
53
#define MIN_HANDSHAKE_SIZE 6
106
83
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
107
84
extern uint32_t tc_heuristic_recover;
88
Local storage for proto that are tmp table. This should be enlarged
89
to hande the entire table-share for a local table. Once Hash is done,
90
we should consider exchanging the map for it.
92
typedef std::map <std::string, message::Table> ProtoCache;
95
The COPY_INFO structure is used by INSERT/REPLACE code.
96
The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY
98
If a row is inserted then the copied variable is incremented.
99
If a row is updated by the INSERT ... ON DUPLICATE KEY UPDATE and the
100
new data differs from the old one then the copied and the updated
101
variables are incremented.
102
The touched variable is incremented if a row was touched by the update part
103
of the INSERT ... ON DUPLICATE KEY UPDATE no matter whether the row
104
was actually changed or not.
106
typedef struct st_copy_info
108
ha_rows records; /**< Number of processed records */
109
ha_rows deleted; /**< Number of deleted records */
110
ha_rows updated; /**< Number of updated records */
111
ha_rows copied; /**< Number of copied records */
113
ha_rows touched; /* Number of touched records */
114
enum enum_duplicates handle_duplicates;
115
int escape_char, last_errno;
117
/* for INSERT ... UPDATE */
118
List<Item> *update_fields;
119
List<Item> *update_values;
120
/* for VIEW ... WITH CHECK OPTION */
123
typedef struct drizzled_lock_st
126
uint32_t table_count;
128
THR_LOCK_DATA **locks;
131
} /* namespace drizzled */
133
/** @TODO why is this in the middle of the file */
134
#include <drizzled/lex_column.h>
109
142
#define Session_SENTRY_MAGIC 0xfeedd1ff
110
143
#define Session_SENTRY_GONE 0xdeadbeef
112
extern DRIZZLED_API struct drizzle_system_variables global_system_variables;
145
#define Session_CHECK_SENTRY(session) assert(session->dbug_sentry == Session_SENTRY_MAGIC)
147
struct system_variables
149
system_variables() {};
151
How dynamically allocated system variables are handled:
153
The global_system_variables and max_system_variables are "authoritative"
154
They both should have the same 'version' and 'size'.
155
When attempting to access a dynamic variable, if the session version
156
is out of date, then the session version is updated and realloced if
157
neccessary and bytes copied from global to make up for missing data.
159
ulong dynamic_variables_version;
160
char * dynamic_variables_ptr;
161
uint32_t dynamic_variables_head; /* largest valid variable offset */
162
uint32_t dynamic_variables_size; /* how many bytes are in use */
164
uint64_t myisam_max_extra_sort_file_size;
165
uint64_t max_heap_table_size;
166
uint64_t tmp_table_size;
167
ha_rows select_limit;
168
ha_rows max_join_size;
169
uint64_t auto_increment_increment;
170
uint64_t auto_increment_offset;
171
uint64_t bulk_insert_buff_size;
172
uint64_t join_buff_size;
173
uint32_t max_allowed_packet;
174
uint64_t max_error_count;
175
uint64_t max_length_for_sort_data;
176
size_t max_sort_length;
177
uint64_t min_examined_row_limit;
178
bool optimizer_prune_level;
181
uint32_t optimizer_search_depth;
182
uint32_t div_precincrement;
183
uint64_t preload_buff_size;
184
uint32_t read_buff_size;
185
uint32_t read_rnd_buff_size;
186
size_t sortbuff_size;
187
uint32_t thread_handling;
188
uint32_t tx_isolation;
189
uint32_t completion_type;
190
/* Determines which non-standard SQL behaviour should be enabled */
192
uint64_t max_seeks_for_key;
193
size_t range_alloc_block_size;
194
uint32_t query_alloc_block_size;
195
uint32_t query_prealloc_size;
196
uint64_t group_concat_max_len;
197
uint64_t pseudo_thread_id;
199
plugin::StorageEngine *storage_engine;
201
/* Only charset part of these variables is sensible */
202
const CHARSET_INFO *character_set_filesystem;
204
/* Both charset and collation parts of these variables are important */
205
const CHARSET_INFO *collation_server;
207
inline const CHARSET_INFO *getCollation(void)
209
return collation_server;
213
MY_LOCALE *lc_time_names;
215
Time_zone *time_zone;
218
extern struct system_variables global_system_variables;
220
} /* namespace drizzled */
222
#include "drizzled/sql_lex.h"
228
* Per-session local status counters
230
typedef struct system_status_var
232
uint64_t bytes_received;
235
ulong com_stat[(uint32_t) SQLCOM_END];
236
ulong created_tmp_disk_tables;
237
ulong created_tmp_tables;
238
ulong ha_commit_count;
239
ulong ha_delete_count;
240
ulong ha_read_first_count;
241
ulong ha_read_last_count;
242
ulong ha_read_key_count;
243
ulong ha_read_next_count;
244
ulong ha_read_prev_count;
245
ulong ha_read_rnd_count;
246
ulong ha_read_rnd_next_count;
247
ulong ha_rollback_count;
248
ulong ha_update_count;
249
ulong ha_write_count;
250
ulong ha_prepare_count;
251
ulong ha_savepoint_count;
252
ulong ha_savepoint_rollback_count;
254
/* KEY_CACHE parts. These are copies of the original */
255
ulong key_blocks_changed;
256
ulong key_blocks_used;
257
ulong key_cache_r_requests;
258
ulong key_cache_read;
259
ulong key_cache_w_requests;
260
ulong key_cache_write;
261
/* END OF KEY_CACHE parts */
263
ulong net_big_packet_count;
264
ulong select_full_join_count;
265
ulong select_full_range_join_count;
266
ulong select_range_count;
267
ulong select_range_check_count;
268
ulong select_scan_count;
269
ulong long_query_count;
270
ulong filesort_merge_passes;
271
ulong filesort_range_count;
273
ulong filesort_scan_count;
275
Number of statements sent from the client
281
SEE last_system_status_var DEFINITION BELOW.
283
Below 'last_system_status_var' are all variables which doesn't make any
284
sense to add to the /global/ status variable counter.
286
double last_query_cost;
290
This is used for 'SHOW STATUS'. It must be updated to the last ulong
291
variable in system_status_var which is makes sens to add to the global
295
#define last_system_status_var questions
297
void mark_transaction_to_rollback(Session *session, bool all);
299
extern pthread_mutex_t LOCK_xid_cache;
300
extern HASH xid_cache;
304
Storage engine specific thread local data.
309
Storage engine specific thread local data.
310
Lifetime: one user connection.
314
* Resource contexts for both the "statement" and "normal"
317
* Resource context at index 0:
319
* Life time: one statement within a transaction. If @@autocommit is
320
* on, also represents the entire transaction.
322
* Resource context at index 1:
324
* Life time: one transaction within a connection.
328
* If the storage engine does not participate in a transaction,
329
* there will not be a resource context.
331
drizzled::ResourceContext resource_context[2];
333
Ha_data() :ha_ptr(NULL) {}
115
337
* Represents a client connection to the database server.
161
369
enum enum_mark_columns mark_used_columns;
370
inline void* alloc(size_t size)
372
return alloc_root(mem_root,size);
162
374
inline void* calloc(size_t size)
165
if ((ptr= mem_root->alloc_root(size)))
377
if ((ptr= alloc_root(mem_root,size)))
166
378
memset(ptr, 0, size);
381
inline char *strdup(const char *str)
383
return strdup_root(mem_root,str);
169
385
inline char *strmake(const char *str, size_t size)
171
return mem_root->strmake_root(str,size);
387
return strmake_root(mem_root,str,size);
389
inline void *memdup(const void *str, size_t size)
391
return memdup_root(mem_root,str,size);
174
393
inline void *memdup_w_gap(const void *str, size_t size, uint32_t gap)
177
if ((ptr= mem_root->alloc_root(size + gap)))
396
if ((ptr= alloc_root(mem_root,size+gap)))
178
397
memcpy(ptr,str,size);
181
400
/** Frees all items attached to this Statement */
182
401
void free_items();
185
403
* List of items created in the parser for this query. Every item puts
186
404
* itself to the list on creation (see Item::Item() for details))
189
407
memory::Root *mem_root; /**< Pointer to current memroot */
192
memory::Root *getMemRoot()
204
void setXaId(uint64_t in_xa_id)
210
409
* Uniquely identifies each statement object in thread scope; change during
211
410
* statement lifetime.
314
439
static const char * const DEFAULT_WHERE;
316
441
memory::Root warn_root; /**< Allocation area for warnings and errors */
318
442
plugin::Client *client; /**< Pointer to client object */
322
void setClient(plugin::Client *client_arg);
324
plugin::Client *getClient()
329
plugin::Client *getClient() const
334
443
plugin::Scheduler *scheduler; /**< Pointer to scheduler object */
335
444
void *scheduler_arg; /**< Pointer to the optional scheduler argument */
337
typedef boost::unordered_map< std::string, user_var_entry *, util::insensitive_hash, util::insensitive_equal_to> UserVars;
340
typedef std::pair< UserVars::iterator, UserVars::iterator > UserVarsRange;
341
UserVars user_vars; /**< Hash of user variables defined during the session's lifetime */
344
const UserVars &getUserVariables() const
349
drizzle_system_variables variables; /**< Mutable local variables local to the session */
351
enum_tx_isolation getTxIsolation()
353
return (enum_tx_isolation)variables.tx_isolation;
445
HASH user_vars; /**< Hash of user variables defined during the session's lifetime */
446
struct system_variables variables; /**< Mutable local variables local to the session */
356
447
struct system_status_var status_var; /**< Session-local status counters */
448
struct system_status_var *initial_status_var; /* used by show status */
357
449
THR_LOCK_INFO lock_info; /**< Locking information for this session */
358
450
THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
359
451
THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
452
pthread_mutex_t LOCK_delete; /**< Locked before session is deleted */
455
* A peek into the query string for the session. This is a best effort
456
* delivery, there is no guarantee whether the content is meaningful.
458
char process_list_info[PROCESS_LIST_WIDTH+1];
362
461
* A pointer to the stack frame of the scheduler thread
365
464
char *thread_stack;
368
identifier::User::shared_ptr security_ctx;
370
int32_t scoreboard_index;
372
inline void checkSentry() const
374
assert(this->dbug_sentry == Session_SENTRY_MAGIC);
467
SecurityContext security_ctx;
378
identifier::User::const_shared_ptr user() const
383
return identifier::User::const_shared_ptr();
386
void setUser(identifier::User::shared_ptr arg)
391
int32_t getScoreboardIndex()
393
return scoreboard_index;
396
void setScoreboardIndex(int32_t in_scoreboard_index)
398
scoreboard_index= in_scoreboard_index;
469
const SecurityContext& getSecurityContext() const
474
SecurityContext& getSecurityContext()
402
480
* Is this session viewable by the current user?
404
bool isViewable(identifier::User::const_reference) const;
482
bool isViewable() const
484
return plugin::Authorization::isAuthorized(current_session->getSecurityContext(),
408
490
Used in error messages to tell user in what part of MySQL we found an
409
491
error. E. g. when where= "having clause", if fix_fields() fails, user
410
492
will know that the error was in having clause.
420
void setWhere(const char *arg)
426
497
One thread can hold up to one named user-level lock. This variable
648
662
create_sort_index(); may differ from examined_row_count.
650
664
uint32_t row_count;
652
uint32_t getRowCount() const
657
session_id_t thread_id;
665
pthread_t real_id; /**< For debugging */
658
667
uint32_t tmp_table;
659
enum global_read_lock_t
662
GOT_GLOBAL_READ_LOCK= 1,
663
MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= 2
666
global_read_lock_t _global_read_lock;
670
global_read_lock_t isGlobalReadLock() const
672
return _global_read_lock;
675
void setGlobalReadLock(global_read_lock_t arg)
677
_global_read_lock= arg;
680
DrizzleLock *lockTables(Table **tables, uint32_t count, uint32_t flags);
681
bool lockGlobalReadLock();
682
bool lock_table_names(TableList *table_list);
683
bool lock_table_names_exclusively(TableList *table_list);
684
bool makeGlobalReadLockBlockCommit();
685
bool abortLockForThread(Table *table);
686
bool wait_if_global_read_lock(bool abort_on_refresh, bool is_not_commit);
687
int lock_table_name(TableList *table_list);
688
void abortLock(Table *table);
689
void removeLock(Table *table);
690
void unlockReadTables(DrizzleLock *sql_lock);
691
void unlockSomeTables(Table **table, uint32_t count);
692
void unlockTables(DrizzleLock *sql_lock);
693
void startWaitingGlobalReadLock();
694
void unlockGlobalReadLock();
697
int unlock_external(Table **table, uint32_t count);
698
int lock_external(Table **tables, uint32_t count);
699
bool wait_for_locked_table_names(TableList *table_list);
700
DrizzleLock *get_lock_data(Table **table_ptr, uint32_t count,
701
bool should_lock, Table **write_lock_used);
668
uint32_t global_read_lock;
704
669
uint32_t server_status;
705
670
uint32_t open_options;
706
671
uint32_t select_number; /**< number of select (used for EXPLAIN) */
1034
980
* Schedule a session to be run on the default scheduler.
1036
static bool schedule(Session::shared_ptr&);
1038
static void unlink(session_id_t &session_id);
1039
static void unlink(Session::shared_ptr&);
1042
985
For enter_cond() / exit_cond() to work the mutex must be got before
1043
986
enter_cond(); this mutex is then released by exit_cond().
1044
987
Usage must be: lock mutex; enter_cond(); your code; exit_cond().
1046
const char* enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg);
989
const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, const char* msg);
1047
990
void exit_cond(const char* old_msg);
1049
type::Time::epoch_t query_start()
1051
return getCurrentTimestampEpoch();
1056
_end_timer= _start_timer= boost::posix_time::microsec_clock::universal_time();
1057
utime_after_lock= (_start_timer - _epoch).total_microseconds();
1060
void set_time(time_t t) // This is done by a sys_var, as long as user_time is set, we will use that for all references to time
1062
_user_time= boost::posix_time::from_time_t(t);
1065
void set_time_after_lock()
1067
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
1068
utime_after_lock= (mytime - _epoch).total_microseconds();
1071
void set_end_timer()
1073
_end_timer= boost::posix_time::microsec_clock::universal_time();
1074
status_var.execution_time_nsec+=(_end_timer - _start_timer).total_microseconds();
1077
uint64_t getElapsedTime() const
1079
return (_end_timer - _start_timer).total_microseconds();
992
inline time_t query_start() { return start_time; }
993
inline void set_time()
997
start_time= user_time;
998
connect_microseconds= start_utime= utime_after_lock= my_micro_time();
1001
start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
1003
inline void set_current_time() { start_time= time(NULL); }
1004
inline void set_time(time_t t)
1006
start_time= user_time= t;
1007
start_utime= utime_after_lock= my_micro_time();
1009
void set_time_after_lock() { utime_after_lock= my_micro_time(); }
1083
1011
* Returns the current micro-timestamp
1085
type::Time::epoch_t getCurrentTimestamp(bool actual= true) const
1087
type::Time::epoch_t t_mark;
1091
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
1092
t_mark= (mytime - _epoch).total_microseconds();
1096
t_mark= (_end_timer - _epoch).total_microseconds();
1102
// We may need to set user on this
1103
type::Time::epoch_t getCurrentTimestampEpoch() const
1105
if (not _user_time.is_not_a_date_time())
1106
return (_user_time - _epoch).total_seconds();
1108
return (_start_timer - _epoch).total_seconds();
1111
type::Time::epoch_t getCurrentTimestampEpoch(type::Time::usec_t &fraction_arg) const
1113
if (not _user_time.is_not_a_date_time())
1116
return (_user_time - _epoch).total_seconds();
1119
fraction_arg= _start_timer.time_of_day().fractional_seconds() % 1000000;
1120
return (_start_timer - _epoch).total_seconds();
1123
uint64_t found_rows(void) const
1013
inline uint64_t getCurrentTimestamp()
1015
return my_micro_time();
1017
inline uint64_t found_rows(void)
1125
1019
return limit_found_rows;
1128
1021
/** Returns whether the session is currently inside a transaction */
1129
bool inTransaction() const
1022
inline bool inTransaction()
1131
1024
return server_status & SERVER_STATUS_IN_TRANS;
1026
inline bool fill_derived_tables()
1028
return !lex->only_view_structure();
1134
1031
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1135
1032
const char* str, uint32_t length,
1136
1033
bool allocate_lex_string);
1138
1034
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1139
1035
const std::string &str,
1140
1036
bool allocate_lex_string);
1142
1038
int send_explain_fields(select_result *result);
1145
1040
Clear the current error, if any.
1146
1041
We do not clear is_fatal_error or is_fatal_sub_stmt_error since we
1373
1246
statement_message= in_message;
1377
* Sets the active Resultset message used by the Query Cache
1380
* @param[in] Pointer to the message
1382
void setResultsetMessage(message::Resultset *in_message)
1384
resultset= in_message;
1387
* reset the active Resultset message used by the Query Cache
1391
void resetResultsetMessage()
1397
1249
/** Pointers to memory managed by the ReplicationServices component */
1398
1250
message::Transaction *transaction_message;
1399
1251
message::Statement *statement_message;
1400
/* Pointer to the current resultset of Select query */
1401
message::Resultset *resultset;
1402
plugin::EventObserverList *session_event_observers;
1404
/* Schema observers are mapped to databases. */
1405
std::map<std::string, plugin::EventObserverList *> schema_event_observers;
1409
plugin::EventObserverList *getSessionObservers()
1411
return session_event_observers;
1414
void setSessionObservers(plugin::EventObserverList *observers)
1416
session_event_observers= observers;
1419
/* For schema event observers there is one set of observers per database. */
1420
plugin::EventObserverList *getSchemaObservers(const std::string &db_name)
1422
std::map<std::string, plugin::EventObserverList *>::iterator it;
1424
it= schema_event_observers.find(db_name);
1425
if (it == schema_event_observers.end())
1431
void setSchemaObservers(const std::string &db_name, plugin::EventObserverList *observers)
1433
std::map<std::string, plugin::EventObserverList *>::iterator it;
1435
it= schema_event_observers.find(db_name);
1436
if (it != schema_event_observers.end())
1437
schema_event_observers.erase(it);;
1440
schema_event_observers[db_name] = observers;
1252
/** Microsecond timestamp of when Session connected */
1253
uint64_t connect_microseconds;
1445
1254
const char *proc_info;
1447
1256
/** The current internal error handler for this thread, or NULL. */
1567
1384
bool openTablesLock(TableList *tables);
1387
* Open all tables in list and process derived tables
1389
* @param Pointer to a list of tables for open
1390
* @param Bitmap of flags to modify how the tables will be open:
1391
* DRIZZLE_LOCK_IGNORE_FLUSH - open table even if someone has
1392
* done a flush or namelock on it.
1401
* This is to be used on prepare stage when you don't read any
1402
* data from the tables.
1404
bool openTables(TableList *tables, uint32_t flags= 0);
1569
1406
int open_tables_from_list(TableList **start, uint32_t *counter, uint32_t flags= 0);
1571
1408
Table *openTableLock(TableList *table_list, thr_lock_type lock_type);
1572
1409
Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1574
1411
void unlink_open_table(Table *find);
1575
void drop_open_table(Table *table, const identifier::Table &identifier);
1412
void drop_open_table(Table *table, TableIdentifier &identifier);
1576
1413
void close_cached_table(Table *table);
1578
1415
/* Create a lock in the cache */
1579
table::Placeholder *table_cache_insert_placeholder(const identifier::Table &identifier);
1580
bool lock_table_name_if_not_cached(const identifier::Table &identifier, Table **table);
1416
Table *table_cache_insert_placeholder(const char *key, uint32_t key_length);
1417
bool lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table);
1418
bool lock_table_name_if_not_cached(const char *db,
1419
const char *table_name, Table **table);
1421
typedef drizzled::hash_map<std::string, message::Table> TableMessageCache;
1422
TableMessageCache table_message_cache;
1424
bool storeTableMessage(TableIdentifier &identifier, message::Table &table_message);
1425
bool removeTableMessage(TableIdentifier &identifier);
1426
bool getTableMessage(TableIdentifier &identifier, message::Table &table_message);
1427
bool doesTableMessageExist(TableIdentifier &identifier);
1428
bool renameTableMessage(TableIdentifier &from, TableIdentifier &to);
1430
/* Work with temporary tables */
1431
Table *find_temporary_table(TableList *table_list);
1432
Table *find_temporary_table(const char *db, const char *table_name);
1433
Table *find_temporary_table(TableIdentifier &identifier);
1435
void doGetTableNames(CachedDirectory &directory,
1436
const std::string& db_name,
1437
std::set<std::string>& set_of_names);
1438
void doGetTableNames(const std::string& db_name,
1439
std::set<std::string>& set_of_names);
1441
int doGetTableDefinition(drizzled::TableIdentifier &identifier,
1442
message::Table &table_proto);
1443
bool doDoesTableExist(TableIdentifier &identifier);
1445
void close_temporary_tables();
1446
void close_temporary_table(Table *table);
1447
// The method below just handles the de-allocation of the table. In
1448
// a better memory type world, this would not be needed.
1583
session::TableMessages _table_message_cache;
1450
void close_temporary(Table *table);
1586
session::TableMessages &getMessageCache()
1588
return _table_message_cache;
1453
int drop_temporary_table(TableList *table_list);
1454
bool rm_temporary_table(plugin::StorageEngine *base, const char *path);
1455
bool rm_temporary_table(TableIdentifier &identifier);
1456
Table *open_temporary_table(TableIdentifier &identifier,
1457
bool link_in_list= true);
1591
1459
/* Reopen operations */
1592
bool reopen_tables();
1460
bool reopen_tables(bool get_locks, bool mark_share_as_old);
1461
bool reopen_name_locked_table(TableList* table_list, bool link_in);
1593
1462
bool close_cached_tables(TableList *tables, bool wait_for_refresh, bool wait_for_placeholders);
1595
void wait_for_condition(boost::mutex &mutex, boost::condition_variable_any &cond);
1464
void wait_for_condition(pthread_mutex_t *mutex, pthread_cond_t *cond);
1596
1465
int setup_conds(TableList *leaves, COND **conds);
1597
1466
int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1599
drizzled::util::Storable *getProperty(const std::string &arg)
1601
return life_properties.getProperty(arg);
1605
bool setProperty(const std::string &arg, T *value)
1607
life_properties.setProperty(arg, value);
1613
1470
Return the default storage engine
1622
1479
if (variables.storage_engine)
1623
1480
return variables.storage_engine;
1624
1481
return global_system_variables.storage_engine;
1627
void get_xid(DrizzleXid *xid); // Innodb only
1629
table::Singular *getInstanceTable();
1630
table::Singular *getInstanceTable(List<CreateField> &field_list);
1635
if (getrusage(RUSAGE_THREAD, &usage))
1645
void setUsage(bool arg)
1650
const struct rusage &getUsage()
1655
catalog::Instance::const_reference catalog() const
1657
return *(_catalog.get());
1660
catalog::Instance::reference catalog()
1662
return *(_catalog.get());
1666
catalog::Instance::shared_ptr _catalog;
1668
// This lives throughout the life of Session
1670
session::PropertyMap life_properties;
1671
std::vector<table::Singular *> temporary_shares;
1672
struct rusage usage;
1484
static void unlink(Session *session);
1675
1490
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
1492
} /* namespace drizzled */
1494
/** @TODO why is this in the middle of the file */
1495
#include <drizzled/select_to_file.h>
1496
#include <drizzled/select_export.h>
1497
#include <drizzled/select_dump.h>
1498
#include <drizzled/select_insert.h>
1499
#include <drizzled/select_create.h>
1500
#include <drizzled/tmp_table_param.h>
1501
#include <drizzled/select_union.h>
1502
#include <drizzled/select_subselect.h>
1503
#include <drizzled/select_singlerow_subselect.h>
1504
#include <drizzled/select_max_min_finder_subselect.h>
1505
#include <drizzled/select_exists_subselect.h>
1511
* A structure used to describe sort information
1512
* for a field or item used in ORDER BY.
1514
typedef struct st_sort_field
1516
Field *field; /**< Field to sort */
1517
Item *item; /**< Item if not sorting fields */
1518
size_t length; /**< Length of sort field */
1519
uint32_t suffix_length; /**< Length suffix (0-4) */
1520
Item_result result_type; /**< Type of item */
1521
bool reverse; /**< if descending sort */
1522
bool need_strxnfrm; /**< If we have to use strxnfrm() */
1525
typedef struct st_sort_buffer
1527
uint32_t index; /* 0 or 1 */
1528
uint32_t sort_orders;
1529
uint32_t change_pos; /* If sort-fields changed */
1531
SORT_FIELD *sortorder;
1534
} /* namespace drizzled */
1536
/** @TODO why is this in the middle of the file */
1538
#include <drizzled/table_ident.h>
1539
#include <drizzled/user_var_entry.h>
1540
#include <drizzled/unique.h>
1541
#include <drizzled/my_var.h>
1542
#include <drizzled/select_dumpvar.h>
1677
1547
/* Bits in sql_command_flags */
1679
1549
enum sql_command_flag_bits