167
167
// requires under some setup non const, you must copy the QueryString in
168
168
// order to use it.
170
void resetQueryString();
171
const boost::shared_ptr<session::State>& state();
170
173
QueryString getQueryString() const
175
void resetQueryString()
182
We need to copy the lock on the string in order to make sure we have a stable string.
183
Once this is done we can use it to build a const char* which can be handed off for
184
a method to use (Innodb is currently the only engine using this).
186
const char *getQueryStringCopy(size_t &length)
178
const char* getQueryStringCopy(size_t &length)
188
180
QueryString tmp_string(getQueryString());
190
181
if (not tmp_string)
196
186
length= tmp_string->length();
197
char *to_return= strmake(tmp_string->c_str(), tmp_string->length());
202
boost::shared_ptr<session::State> _state;
206
const boost::shared_ptr<session::State>& state()
212
Name of the current (default) database.
214
If there is the current (default) database, "db" contains its name. If
215
there is no current (default) database, "db" is NULL and "db_length" is
216
0. In other words, "db", "db_length" must either be NULL, or contain a
219
@note this attribute is set and alloced by the slave SQL thread (for
220
the Session of that thread); that thread is (and must remain, for now) the
221
only responsible for freeing this member.
225
util::string::const_shared_ptr schema() const
227
return _schema ? _schema : util::string::const_shared_ptr(new std::string);
187
return strmake(tmp_string->c_str(), tmp_string->length());
190
util::string::ptr schema() const;
230
192
/* current cache key */
231
193
std::string query_cache_key;
358
320
* Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
359
321
* first byte of the packet in executeStatement()
361
enum enum_server_command command;
362
uint32_t file_id; /**< File ID for LOAD DATA INFILE */
363
/* @note the following three members should likely move to Client */
364
uint32_t max_client_packet_length; /**< Maximum number of bytes a client can send in a single packet */
367
boost::posix_time::ptime _epoch;
368
boost::posix_time::ptime _connect_time;
369
boost::posix_time::ptime _start_timer;
370
boost::posix_time::ptime _end_timer;
372
boost::posix_time::ptime _user_time;
374
uint64_t utime_after_lock; // This used by Innodb.
378
_user_time= boost::posix_time::not_a_date_time;
381
const boost::posix_time::ptime &start_timer() const
386
void getTimeDifference(boost::posix_time::time_duration &result_arg, const boost::posix_time::ptime &arg) const
388
result_arg= arg - _start_timer;
323
enum_server_command command;
391
325
thr_lock_type update_lock_default;
803
738
void cleanup_after_query();
805
740
void awake(Session::killed_state_t state_to_set);
807
* Pulls thread-specific variables into Session state.
809
* Returns true most times, or false if there was a problem
810
* allocating resources for thread-specific storage.
812
* @TODO Kill this. It's not necessary once my_thr_init() is bye bye.
818
743
Initialize memory roots necessary for query processing and (!)
875
800
* Returns true on success, or false on failure.
877
802
bool authenticate();
882
* This will initialize the session and begin the command loop.
887
* Schedule a session to be run on the default scheduler.
889
804
static bool schedule(Session::shared_ptr&);
891
static void unlink(session_id_t &session_id);
805
static void unlink(session_id_t&);
892
806
static void unlink(Session::shared_ptr&);
899
813
const char* enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg);
900
814
void exit_cond(const char* old_msg);
902
type::Time::epoch_t query_start()
904
return getCurrentTimestampEpoch();
909
_end_timer= _start_timer= boost::posix_time::microsec_clock::universal_time();
910
utime_after_lock= (_start_timer - _epoch).total_microseconds();
913
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
915
_user_time= boost::posix_time::from_time_t(t);
918
void set_time_after_lock()
920
utime_after_lock= (boost::posix_time::microsec_clock::universal_time() - _epoch).total_microseconds();
923
void set_end_timer();
925
uint64_t getElapsedTime() const
927
return (_end_timer - _start_timer).total_microseconds();
931
* Returns the current micro-timestamp
933
type::Time::epoch_t getCurrentTimestamp(bool actual= true) const
935
return ((actual ? boost::posix_time::microsec_clock::universal_time() : _end_timer) - _epoch).total_microseconds();
938
// We may need to set user on this
939
type::Time::epoch_t getCurrentTimestampEpoch() const
941
return ((_user_time.is_not_a_date_time() ? _start_timer : _user_time) - _epoch).total_seconds();
944
type::Time::epoch_t getCurrentTimestampEpoch(type::Time::usec_t &fraction_arg) const
946
if (not _user_time.is_not_a_date_time())
949
return (_user_time - _epoch).total_seconds();
952
fraction_arg= _start_timer.time_of_day().fractional_seconds() % 1000000;
953
return (_start_timer - _epoch).total_seconds();
956
816
uint64_t found_rows() const
958
818
return limit_found_rows;
1098
958
bool checkUser(const std::string &passwd, const std::string &db);
1101
* Returns the timestamp (in microseconds) of when the Session
1102
* connected to the server.
1104
uint64_t getConnectMicroseconds() const
1106
return (_connect_time - _epoch).total_microseconds();
1109
uint64_t getConnectSeconds() const
1111
return (_connect_time - _epoch).total_seconds();
1115
961
* Returns a pointer to the active Transaction message for this
1116
962
* Session being managed by the ReplicationServices component, or
1117
963
* NULL if no active message.