38
38
#include <drizzled/copy_info.h>
39
39
#include <drizzled/cursor.h>
40
40
#include <drizzled/diagnostics_area.h>
41
#include <drizzled/error.h>
41
42
#include <drizzled/file_exchange.h>
42
43
#include <drizzled/ha_data.h>
43
44
#include <drizzled/identifier.h>
175
175
inline void *memdup_w_gap(const void *str, size_t size, uint32_t gap)
178
if ((ptr= mem_root->alloc_root(size + gap)))
179
memcpy(ptr,str,size);
177
void *ptr= mem_root->alloc_root(size + gap);
179
memcpy(ptr, str, size);
182
182
/** Frees all items attached to this Statement */
211
* Uniquely identifies each statement object in thread scope; change during
212
* statement lifetime.
214
* @todo should be const
219
const LEX* getLex() const
208
const LEX& lex() const
228
218
enum_sql_command getSqlCommand() const
230
return getLex()->sql_command;
220
return lex().sql_command;
233
223
/** query associated with this statement */
356
346
return (enum_tx_isolation)variables.tx_isolation;
359
struct system_status_var status_var; /**< Session-local status counters */
349
system_status_var status_var; /**< Session-local status counters */
360
350
THR_LOCK_INFO lock_info; /**< Locking information for this session */
361
351
THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
362
352
THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
541
527
return concurrent_execute_allowed;
544
/* Tells if LAST_INSERT_ID(#) was called for the current statement */
545
bool arg_of_last_insert_id_function;
548
531
ALL OVER THIS FILE, "insert_id" means "*automatically generated* value for
549
532
insertion into an auto_increment column".
773
756
bool substitute_null_with_insert_id;
774
757
bool cleanup_done;
777
bool abort_on_warning;
778
bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
781
760
bool got_warning; /**< Set on call to push_warning() */
782
761
bool no_warnings_for_error; /**< no warnings on call to my_error() */
783
762
/** set during loop of derived table processing */
784
763
bool derived_tables_processing;
786
bool doing_tablespace_operation(void)
765
bool doing_tablespace_operation()
788
767
return tablespace_op;
919
898
if (first_successful_insert_id_in_cur_stmt == 0)
920
899
first_successful_insert_id_in_cur_stmt= id_arg;
922
inline uint64_t read_first_successful_insert_id_in_prev_stmt(void)
901
inline uint64_t read_first_successful_insert_id_in_prev_stmt()
924
903
return first_successful_insert_id_in_prev_stmt;
1068
1047
void set_time_after_lock()
1070
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
1071
utime_after_lock= (mytime - _epoch).total_microseconds();
1049
utime_after_lock= (boost::posix_time::microsec_clock::universal_time() - _epoch).total_microseconds();
1074
1052
void set_end_timer()
1088
1066
type::Time::epoch_t getCurrentTimestamp(bool actual= true) const
1090
type::Time::epoch_t t_mark;
1094
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
1095
t_mark= (mytime - _epoch).total_microseconds();
1099
t_mark= (_end_timer - _epoch).total_microseconds();
1068
return ((actual ? boost::posix_time::microsec_clock::universal_time() : _end_timer) - _epoch).total_microseconds();
1105
1071
// We may need to set user on this
1106
1072
type::Time::epoch_t getCurrentTimestampEpoch() const
1108
if (not _user_time.is_not_a_date_time())
1109
return (_user_time - _epoch).total_seconds();
1111
return (_start_timer - _epoch).total_seconds();
1074
return ((_user_time.is_not_a_date_time() ? _start_timer : _user_time) - _epoch).total_seconds();
1114
1077
type::Time::epoch_t getCurrentTimestampEpoch(type::Time::usec_t &fraction_arg) const
1392
1355
resultset= NULL;
1396
/** Pointers to memory managed by the ReplicationServices component */
1397
message::Transaction *transaction_message;
1398
message::Statement *statement_message;
1399
/* Pointer to the current resultset of Select query */
1400
message::Resultset *resultset;
1401
plugin::EventObserverList *session_event_observers;
1403
/* Schema observers are mapped to databases. */
1404
typedef std::map<std::string, plugin::EventObserverList*> schema_event_observers_t;
1405
schema_event_observers_t schema_event_observers;
1409
1359
plugin::EventObserverList *getSessionObservers()
1491
1440
main_da.set_eof_status(this);
1494
/* Some inline functions for more speed */
1496
inline bool add_item_to_list(Item *item)
1498
return getLex()->current_select->add_item_to_list(this, item);
1501
inline bool add_value_to_list(Item *value)
1503
return getLex()->value_list.push_back(value);
1506
inline bool add_order_to_list(Item *item, bool asc)
1508
return getLex()->current_select->add_order_to_list(this, item, asc);
1511
inline bool add_group_to_list(Item *item, bool asc)
1513
return getLex()->current_select->add_group_to_list(this, item, asc);
1443
bool add_item_to_list(Item *item);
1444
bool add_value_to_list(Item *value);
1445
bool add_order_to_list(Item *item, bool asc);
1446
bool add_group_to_list(Item *item, bool asc);
1515
1448
void refresh_status();
1516
1449
user_var_entry *getVariable(LEX_STRING &name, bool create_if_not_exists);
1517
1450
user_var_entry *getVariable(const std::string &name, bool create_if_not_exists);
1527
1460
void close_open_tables();
1528
1461
void close_data_files_and_morph_locks(const identifier::Table &identifier);
1531
bool free_cached_table(boost::mutex::scoped_lock &scopedLock);
1536
1464
* Prepares statement for reopening of tables and recalculation of set of
1537
1465
* prelocked tables.
1570
1498
table::Placeholder *table_cache_insert_placeholder(const identifier::Table &identifier);
1571
1499
bool lock_table_name_if_not_cached(const identifier::Table &identifier, Table **table);
1574
session::TableMessages _table_message_cache;
1577
1501
session::TableMessages &getMessageCache()
1579
1503
return _table_message_cache;
1595
1519
template<class T>
1596
bool setProperty(const std::string &arg, T *value)
1520
void setProperty(const std::string &arg, T *value)
1598
1522
life_properties.setProperty(arg, value);
1620
1542
table::Singular *getInstanceTable();
1621
1543
table::Singular *getInstanceTable(List<CreateField> &field_list);
1626
if (getrusage(RUSAGE_THREAD, &usage))
1636
1545
void setUsage(bool arg)
1638
1547
use_usage= arg;
1641
const struct rusage &getUsage()
1550
const rusage &getUsage()
1646
1555
catalog::Instance::const_reference catalog() const
1648
return *(_catalog.get());
1651
1560
catalog::Instance::reference catalog()
1653
return *(_catalog.get());
1565
bool arg_of_last_insert_id_function; // Tells if LAST_INSERT_ID(#) was called for the current statement
1569
bool free_cached_table(boost::mutex::scoped_lock &scopedLock);
1573
return not getrusage(RUSAGE_THREAD, &usage);
1576
session::TableMessages _table_message_cache;
1577
boost::scoped_ptr<impl_c> impl_;
1657
1578
catalog::Instance::shared_ptr _catalog;
1659
// This lives throughout the life of Session
1580
/** Pointers to memory managed by the ReplicationServices component */
1581
message::Transaction *transaction_message;
1582
message::Statement *statement_message;
1583
/* Pointer to the current resultset of Select query */
1584
message::Resultset *resultset;
1585
plugin::EventObserverList *session_event_observers;
1587
/* Schema observers are mapped to databases. */
1588
typedef std::map<std::string, plugin::EventObserverList*> schema_event_observers_t;
1589
schema_event_observers_t schema_event_observers;
1592
const char *proc_info;
1593
bool abort_on_warning;
1594
bool concurrent_execute_allowed;
1595
bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
1660
1596
bool use_usage;
1661
1597
session::PropertyMap life_properties;
1662
1598
std::vector<table::Singular *> temporary_shares;
1663
struct rusage usage;
1666
1602
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape