405
395
/** query associated with this statement */
406
typedef boost::shared_ptr<const std::string> QueryString;
408
boost::shared_ptr<std::string> query;
410
// Never allow for a modification of this outside of the class. c_str()
411
// requires under some setup non const, you must copy the QueryString in
414
QueryString getQueryString() const
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)
432
QueryString tmp_string(getQueryString());
441
length= tmp_string->length();
442
char *to_return= strmake(tmp_string->c_str(), tmp_string->length());
447
std::vector <char> _query;
450
typedef boost::shared_ptr<State> const_shared_ptr;
452
State(const char *in_packet, size_t in_packet_length)
454
if (in_packet_length)
456
size_t minimum= std::min(in_packet_length, static_cast<size_t>(PROCESS_LIST_WIDTH));
457
_query.resize(minimum + 1);
458
memcpy(&_query[0], in_packet, minimum);
466
const char *query() const
474
const char *query(size_t &size) const
478
size= _query.size() -1;
486
friend class Session;
487
typedef boost::shared_ptr<State> shared_ptr;
490
State::shared_ptr _state;
493
State::const_shared_ptr state()
499
399
Name of the current (default) database.
532
422
memory::Root warn_root; /**< Allocation area for warnings and errors */
533
423
plugin::Client *client; /**< Pointer to client object */
535
void setClient(plugin::Client *client_arg);
537
plugin::Client *getClient()
542
424
plugin::Scheduler *scheduler; /**< Pointer to scheduler object */
543
425
void *scheduler_arg; /**< Pointer to the optional scheduler argument */
545
427
typedef boost::unordered_map< std::string, user_var_entry *, util::insensitive_hash, util::insensitive_equal_to> UserVars;
547
428
typedef std::pair< UserVars::iterator, UserVars::iterator > UserVarsRange;
548
429
UserVars user_vars; /**< Hash of user variables defined during the session's lifetime */
552
const UserVars &getUserVariables() const
557
432
drizzle_system_variables variables; /**< Mutable local variables local to the session */
558
433
struct system_status_var status_var; /**< Session-local status counters */
559
434
THR_LOCK_INFO lock_info; /**< Locking information for this session */
560
435
THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
561
436
THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
438
boost::mutex LOCK_delete; /**< Locked before session is deleted */
446
void unlockForDelete()
448
LOCK_delete.unlock();
452
* A peek into the query string for the session. This is a best effort
453
* delivery, there is no guarantee whether the content is meaningful.
455
char process_list_info[PROCESS_LIST_WIDTH+1];
564
458
* A pointer to the stack frame of the scheduler thread
616
515
uint32_t dbug_sentry; /**< watch for memory corruption */
618
boost::thread::id boost_thread_id;
619
boost_thread_shared_ptr _thread;
620
boost::this_thread::disable_interruption *interrupt;
622
517
internal::st_my_thread_var *mysys_var;
625
boost_thread_shared_ptr &getThread()
630
void pushInterrupt(boost::this_thread::disable_interruption *interrupt_arg)
632
interrupt= interrupt_arg;
635
boost::this_thread::disable_interruption &getThreadInterupt()
641
520
internal::st_my_thread_var *getThreadVar()
643
522
return mysys_var;
525
void resetThreadVar()
647
530
* Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
648
531
* first byte of the packet in executeStatement()
730
613
Field *dup_field;
731
614
sigset_t signals;
733
// As of right now we do not allow a concurrent execute to launch itself
735
bool concurrent_execute_allowed;
738
void setConcurrentExecute(bool arg)
740
concurrent_execute_allowed= arg;
743
bool isConcurrentExecuteAllowed() const
745
return concurrent_execute_allowed;
748
616
/* Tells if LAST_INSERT_ID(#) was called for the current statement */
749
617
bool arg_of_last_insert_id_function;
752
619
ALL OVER THIS FILE, "insert_id" means "*automatically generated* value for
753
620
insertion into an auto_increment column".
851
718
uint32_t row_count;
852
719
session_id_t thread_id;
853
720
uint32_t tmp_table;
854
enum global_read_lock_t
857
GOT_GLOBAL_READ_LOCK= 1,
858
MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= 2
861
global_read_lock_t _global_read_lock;
865
global_read_lock_t isGlobalReadLock() const
867
return _global_read_lock;
870
void setGlobalReadLock(global_read_lock_t arg)
872
_global_read_lock= arg;
875
DrizzleLock *lockTables(Table **tables, uint32_t count, uint32_t flags, bool *need_reopen);
876
bool lockGlobalReadLock();
877
bool lock_table_names(TableList *table_list);
878
bool lock_table_names_exclusively(TableList *table_list);
879
bool makeGlobalReadLockBlockCommit();
880
bool abortLockForThread(Table *table);
881
bool wait_if_global_read_lock(bool abort_on_refresh, bool is_not_commit);
882
int lock_table_name(TableList *table_list);
883
void abortLock(Table *table);
884
void removeLock(Table *table);
885
void unlockReadTables(DrizzleLock *sql_lock);
886
void unlockSomeTables(Table **table, uint32_t count);
887
void unlockTables(DrizzleLock *sql_lock);
888
void startWaitingGlobalReadLock();
889
void unlockGlobalReadLock();
892
int unlock_external(Table **table, uint32_t count);
893
int lock_external(Table **tables, uint32_t count);
894
bool wait_for_locked_table_names(TableList *table_list);
895
DrizzleLock *get_lock_data(Table **table_ptr, uint32_t count,
896
bool should_lock, Table **write_lock_used);
721
uint32_t global_read_lock;
899
722
uint32_t server_status;
900
723
uint32_t open_options;
901
724
uint32_t select_number; /**< number of select (used for EXPLAIN) */
1228
1045
inline time_t query_start() { return start_time; }
1229
1046
inline void set_time()
1231
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1232
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1233
start_utime= utime_after_lock= (mytime-epoch).total_microseconds();
1237
1050
start_time= user_time;
1238
connect_microseconds= start_utime;
1051
connect_microseconds= start_utime= utime_after_lock= my_micro_time();
1241
start_time= (mytime-epoch).total_seconds();
1054
start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
1243
1056
inline void set_current_time() { start_time= time(NULL); }
1244
1057
inline void set_time(time_t t)
1246
1059
start_time= user_time= t;
1247
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1248
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1249
uint64_t t_mark= (mytime-epoch).total_microseconds();
1251
start_utime= utime_after_lock= t_mark;
1253
void set_time_after_lock() {
1254
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1255
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1256
utime_after_lock= (mytime-epoch).total_microseconds();
1060
start_utime= utime_after_lock= my_micro_time();
1062
void set_time_after_lock() { utime_after_lock= my_micro_time(); }
1259
1064
* Returns the current micro-timestamp
1261
1066
inline uint64_t getCurrentTimestamp()
1263
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1264
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1265
uint64_t t_mark= (mytime-epoch).total_microseconds();
1068
return my_micro_time();
1269
1070
inline uint64_t found_rows(void)
1706
1512
Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1708
1514
void unlink_open_table(Table *find);
1709
void drop_open_table(Table *table, const TableIdentifier &identifier);
1515
void drop_open_table(Table *table, TableIdentifier &identifier);
1710
1516
void close_cached_table(Table *table);
1712
1518
/* Create a lock in the cache */
1713
1519
table::Placeholder *table_cache_insert_placeholder(const TableIdentifier &identifier);
1714
bool lock_table_name_if_not_cached(const TableIdentifier &identifier, Table **table);
1520
bool lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table);
1716
1522
typedef boost::unordered_map<std::string, message::Table, util::insensitive_hash, util::insensitive_equal_to> TableMessageCache;
1720
TableMessageCache table_message_cache;
1723
bool storeTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1724
bool removeTableMessage(const TableIdentifier &identifier);
1725
bool getTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1726
bool doesTableMessageExist(const TableIdentifier &identifier);
1727
bool renameTableMessage(const TableIdentifier &from, const TableIdentifier &to);
1523
TableMessageCache table_message_cache;
1525
bool storeTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1526
bool removeTableMessage(const TableIdentifier &identifier);
1527
bool getTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1528
bool doesTableMessageExist(const TableIdentifier &identifier);
1529
bool renameTableMessage(const TableIdentifier &from, const TableIdentifier &to);
1531
/* Work with temporary tables */
1532
Table *find_temporary_table(const TableIdentifier &identifier);
1534
void doGetTableNames(CachedDirectory &directory,
1535
const SchemaIdentifier &schema_identifier,
1536
std::set<std::string>& set_of_names);
1537
void doGetTableNames(const SchemaIdentifier &schema_identifier,
1538
std::set<std::string>& set_of_names);
1540
void doGetTableIdentifiers(CachedDirectory &directory,
1541
const SchemaIdentifier &schema_identifier,
1542
TableIdentifiers &set_of_identifiers);
1543
void doGetTableIdentifiers(const SchemaIdentifier &schema_identifier,
1544
TableIdentifiers &set_of_identifiers);
1546
int doGetTableDefinition(const drizzled::TableIdentifier &identifier,
1547
message::Table &table_proto);
1548
bool doDoesTableExist(const drizzled::TableIdentifier &identifier);
1550
void close_temporary_tables();
1551
void close_temporary_table(Table *table);
1552
// The method below just handles the de-allocation of the table. In
1553
// a better memory type world, this would not be needed.
1731
TableMessages _table_message_cache;
1555
void nukeTable(Table *table);
1734
TableMessages &getMessageCache()
1736
return _table_message_cache;
1558
void dumpTemporaryTableNames(const char *id);
1559
int drop_temporary_table(const drizzled::TableIdentifier &identifier);
1560
bool rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier);
1561
bool rm_temporary_table(TableIdentifier &identifier, bool best_effort= false);
1562
Table *open_temporary_table(TableIdentifier &identifier,
1563
bool link_in_list= true);
1739
1565
/* Reopen operations */
1740
1566
bool reopen_tables(bool get_locks, bool mark_share_as_old);