36
36
#include "drizzled/transaction_context.h"
37
37
#include "drizzled/util/storable.h"
38
38
#include "drizzled/my_hash.h"
39
#include "drizzled/pthread_globals.h"
43
#include <sys/resource.h>
46
#include "drizzled/internal/getrusage.h"
47
50
#include "drizzled/security_context.h"
48
51
#include "drizzled/open_tables_state.h"
49
52
#include "drizzled/internal_error_handler.h"
51
54
#include "drizzled/plugin/authorization.h"
53
56
#include <boost/unordered_map.hpp>
58
#include <boost/thread/thread.hpp>
54
59
#include <boost/thread/mutex.hpp>
55
60
#include <boost/thread/shared_mutex.hpp>
56
61
#include <boost/thread/condition_variable.hpp>
310
316
// Plugin storage in Session.
311
317
typedef boost::unordered_map<std::string, util::Storable *, util::insensitive_hash, util::insensitive_equal_to> PropertyMap;
318
typedef Session* Ptr;
319
typedef boost::shared_ptr<Session> shared_ptr;
314
322
MARK_COLUMNS_NONE: Means mark_used_colums is not set and no indicator to
395
403
/** query associated with this statement */
404
typedef boost::shared_ptr<const std::string> QueryString;
406
boost::shared_ptr<std::string> query;
408
// Never allow for a modification of this outside of the class. c_str()
409
// requires under some setup non const, you must copy the QueryString in
412
QueryString getQueryString() const
417
void resetQueryString()
419
return query.reset(new std::string);
423
We need to copy the lock on the string in order to make sure we have a stable string.
424
Once this is done we can use it to build a const char* which can be handed off for
425
a method to use (Innodb is currently the only engine using this).
427
const char *getQueryStringCopy(size_t &length)
429
QueryString tmp_string(getQueryString());
431
length= tmp_string->length();
432
char *to_return= strmake(tmp_string->c_str(), tmp_string->length());
399
437
Name of the current (default) database.
422
465
memory::Root warn_root; /**< Allocation area for warnings and errors */
423
466
plugin::Client *client; /**< Pointer to client object */
468
void setClient(plugin::Client *client_arg);
470
plugin::Client *getClient()
424
475
plugin::Scheduler *scheduler; /**< Pointer to scheduler object */
425
476
void *scheduler_arg; /**< Pointer to the optional scheduler argument */
441
492
THR_LOCK_INFO lock_info; /**< Locking information for this session */
442
493
THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
443
494
THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
445
boost::mutex LOCK_delete; /**< Locked before session is deleted */
453
void unlockForDelete()
455
LOCK_delete.unlock();
459
* A peek into the query string for the session. This is a best effort
460
* delivery, there is no guarantee whether the content is meaningful.
462
char process_list_info[PROCESS_LIST_WIDTH+1];
465
497
* A pointer to the stack frame of the scheduler thread
522
549
uint32_t dbug_sentry; /**< watch for memory corruption */
551
boost::thread::id boost_thread_id;
552
boost_thread_shared_ptr _thread;
553
boost::this_thread::disable_interruption *interrupt;
524
555
internal::st_my_thread_var *mysys_var;
558
boost_thread_shared_ptr &getThread()
563
void pushInterrupt(boost::this_thread::disable_interruption *interrupt_arg)
565
interrupt= interrupt_arg;
568
boost::this_thread::disable_interruption &getThreadInterupt()
527
574
internal::st_my_thread_var *getThreadVar()
529
576
return mysys_var;
532
void resetThreadVar()
537
580
* Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
538
581
* first byte of the packet in executeStatement()
620
663
Field *dup_field;
621
664
sigset_t signals;
666
// As of right now we do not allow a concurrent execute to launch itself
668
bool concurrent_execute_allowed;
671
void setConcurrentExecute(bool arg)
673
concurrent_execute_allowed= arg;
676
bool isConcurrentExecuteAllowed() const
678
return concurrent_execute_allowed;
623
681
/* Tells if LAST_INSERT_ID(#) was called for the current statement */
624
682
bool arg_of_last_insert_id_function;
626
685
ALL OVER THIS FILE, "insert_id" means "*automatically generated* value for
627
686
insertion into an auto_increment column".
911
970
return warn_query_id;
914
/** Returns the current query text */
915
inline const std::string &getQueryString() const
920
/** Returns the length of the current query text */
921
inline size_t getQueryLength() const
924
return query.length();
929
973
/** Accessor method returning the session's ID. */
930
974
inline session_id_t getSessionId() const
1102
1146
* Schedule a session to be run on the default scheduler.
1148
static bool schedule(Session::shared_ptr&);
1150
static void unlink(Session::shared_ptr&);
1107
1153
For enter_cond() / exit_cond() to work the mutex must be got before
1114
1160
inline time_t query_start() { return start_time; }
1115
1161
inline void set_time()
1163
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1164
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1165
start_utime= utime_after_lock= (mytime-epoch).total_microseconds();
1119
1169
start_time= user_time;
1120
connect_microseconds= start_utime= utime_after_lock= my_micro_time();
1170
connect_microseconds= start_utime;
1123
start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
1173
start_time= (mytime-epoch).total_seconds();
1125
1175
inline void set_current_time() { start_time= time(NULL); }
1126
1176
inline void set_time(time_t t)
1128
1178
start_time= user_time= t;
1129
start_utime= utime_after_lock= my_micro_time();
1131
void set_time_after_lock() { utime_after_lock= my_micro_time(); }
1179
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1180
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1181
uint64_t t_mark= (mytime-epoch).total_microseconds();
1183
start_utime= utime_after_lock= t_mark;
1185
void set_time_after_lock() {
1186
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1187
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1188
utime_after_lock= (mytime-epoch).total_microseconds();
1133
1191
* Returns the current micro-timestamp
1135
1193
inline uint64_t getCurrentTimestamp()
1137
return my_micro_time();
1195
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1196
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1197
uint64_t t_mark= (mytime-epoch).total_microseconds();
1139
1201
inline uint64_t found_rows(void)
1160
1222
@todo: To silence an error, one should use Internal_error_handler
1161
1223
mechanism. In future this function will be removed.
1163
inline void clear_error()
1225
inline void clear_error(bool full= false)
1165
1227
if (main_da.is_error())
1166
1228
main_da.reset_diagnostics_area();
1232
drizzle_reset_errors(this, true);
1236
void clearDiagnostics()
1238
main_da.reset_diagnostics_area();
1534
1605
void close_old_data_files(bool morph_locks= false,
1535
1606
bool send_refresh= false);
1536
1607
void close_open_tables();
1537
void close_data_files_and_morph_locks(TableIdentifier &identifier);
1608
void close_data_files_and_morph_locks(const TableIdentifier &identifier);
1540
1611
bool free_cached_table();
1571
1642
Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1573
1644
void unlink_open_table(Table *find);
1574
void drop_open_table(Table *table, TableIdentifier &identifier);
1645
void drop_open_table(Table *table, const TableIdentifier &identifier);
1575
1646
void close_cached_table(Table *table);
1577
1648
/* Create a lock in the cache */
1578
1649
table::Placeholder *table_cache_insert_placeholder(const TableIdentifier &identifier);
1579
bool lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table);
1650
bool lock_table_name_if_not_cached(const TableIdentifier &identifier, Table **table);
1581
1652
typedef boost::unordered_map<std::string, message::Table, util::insensitive_hash, util::insensitive_equal_to> TableMessageCache;
1754
1823
static const std::bitset<CF_BIT_SIZE> CF_SHOW_TABLE_COMMAND(1 << CF_BIT_SHOW_TABLE_COMMAND);
1755
1824
static const std::bitset<CF_BIT_SIZE> CF_WRITE_LOGS_COMMAND(1 << CF_BIT_WRITE_LOGS_COMMAND);
1827
const std::string &type(drizzled::Session::global_read_lock_t type);
1828
size_t max_string_length(drizzled::Session::global_read_lock_t type);
1829
} /* namespace display */
1757
1831
} /* namespace drizzled */
1759
1833
#endif /* DRIZZLED_SESSION_H */