31
31
#include <drizzled/sql_error.h>
32
32
#include <drizzled/file_exchange.h>
33
33
#include <drizzled/select_result_interceptor.h>
34
#include <drizzled/statistics_variables.h>
34
35
#include <drizzled/xid.h>
35
36
#include "drizzled/query_id.h"
36
37
#include "drizzled/named_savepoint.h"
222
227
namespace drizzled
226
* Per-session local status counters
228
typedef struct system_status_var
230
uint64_t bytes_received;
233
ulong com_stat[(uint32_t) SQLCOM_END];
234
ulong created_tmp_disk_tables;
235
ulong created_tmp_tables;
236
ulong ha_commit_count;
237
ulong ha_delete_count;
238
ulong ha_read_first_count;
239
ulong ha_read_last_count;
240
ulong ha_read_key_count;
241
ulong ha_read_next_count;
242
ulong ha_read_prev_count;
243
ulong ha_read_rnd_count;
244
ulong ha_read_rnd_next_count;
245
ulong ha_rollback_count;
246
ulong ha_update_count;
247
ulong ha_write_count;
248
ulong ha_prepare_count;
249
ulong ha_savepoint_count;
250
ulong ha_savepoint_rollback_count;
252
/* KEY_CACHE parts. These are copies of the original */
253
ulong key_blocks_changed;
254
ulong key_blocks_used;
255
ulong key_cache_r_requests;
256
ulong key_cache_read;
257
ulong key_cache_w_requests;
258
ulong key_cache_write;
259
/* END OF KEY_CACHE parts */
261
ulong net_big_packet_count;
262
ulong select_full_join_count;
263
ulong select_full_range_join_count;
264
ulong select_range_count;
265
ulong select_range_check_count;
266
ulong select_scan_count;
267
ulong long_query_count;
268
ulong filesort_merge_passes;
269
ulong filesort_range_count;
271
ulong filesort_scan_count;
273
Number of statements sent from the client
279
SEE last_system_status_var DEFINITION BELOW.
281
Below 'last_system_status_var' are all variables which doesn't make any
282
sense to add to the /global/ status variable counter.
284
double last_query_cost;
288
This is used for 'SHOW STATUS'. It must be updated to the last ulong
289
variable in system_status_var which is makes sens to add to the global
293
#define last_system_status_var questions
295
230
void mark_transaction_to_rollback(Session *session, bool all);
297
232
extern pthread_mutex_t LOCK_xid_cache;
298
233
extern HASH xid_cache;
302
236
Storage engine specific thread local data.
367
301
enum enum_mark_columns mark_used_columns;
368
302
inline void* alloc(size_t size)
370
return alloc_root(mem_root,size);
304
return mem_root->alloc_root(size);
372
306
inline void* calloc(size_t size)
375
if ((ptr= alloc_root(mem_root,size)))
309
if ((ptr= mem_root->alloc_root(size)))
376
310
memset(ptr, 0, size);
379
313
inline char *strdup(const char *str)
381
return strdup_root(mem_root,str);
315
return mem_root->strdup_root(str);
383
317
inline char *strmake(const char *str, size_t size)
385
return strmake_root(mem_root,str,size);
319
return mem_root->strmake_root(str,size);
387
321
inline void *memdup(const void *str, size_t size)
389
return memdup_root(mem_root,str,size);
323
return mem_root->memdup_root(str, size);
391
325
inline void *memdup_w_gap(const void *str, size_t size, uint32_t gap)
394
if ((ptr= alloc_root(mem_root,size+gap)))
328
if ((ptr= mem_root->alloc_root(size + gap)))
395
329
memcpy(ptr,str,size);
1104
1056
return (abort_on_warning);
1106
1058
void set_status_var_init();
1107
void reset_n_backup_open_tables_state(Open_tables_state *backup);
1108
void restore_backup_open_tables_state(Open_tables_state *backup);
1111
1061
Set the current database; use deep copy of C-string.
1252
1202
/** Pointers to memory managed by the ReplicationServices component */
1253
1203
message::Transaction *transaction_message;
1254
1204
message::Statement *statement_message;
1255
/** Microsecond timestamp of when Session connected */
1205
plugin::EventObserverList *session_event_observers;
1207
/* Schema observers are mapped to databases. */
1208
std::map<std::string, plugin::EventObserverList *> schema_event_observers;
1212
plugin::EventObserverList *getSessionObservers()
1214
return session_event_observers;
1217
void setSessionObservers(plugin::EventObserverList *observers)
1219
session_event_observers= observers;
1222
/* For schema event observers there is one set of observers per database. */
1223
plugin::EventObserverList *getSchemaObservers(const std::string &db_name)
1225
std::map<std::string, plugin::EventObserverList *>::iterator it;
1227
it= schema_event_observers.find(db_name);
1228
if (it == schema_event_observers.end())
1234
void setSchemaObservers(const std::string &db_name, plugin::EventObserverList *observers)
1236
std::map<std::string, plugin::EventObserverList *>::iterator it;
1238
it= schema_event_observers.find(db_name);
1239
if (it != schema_event_observers.end())
1240
schema_event_observers.erase(it);;
1243
schema_event_observers[db_name] = observers;
1248
/** Microsecond timestamp of when Session connected */
1256
1249
uint64_t connect_microseconds;
1257
1250
const char *proc_info;
1355
1348
bool send_refresh= false);
1356
1349
void close_open_tables();
1357
1350
void close_data_files_and_morph_locks(TableIdentifier &identifier);
1358
void close_data_files_and_morph_locks(const char *db, const char *table_name);
1361
1353
bool free_cached_table();
1416
1408
void close_cached_table(Table *table);
1418
1410
/* Create a lock in the cache */
1419
Table *table_cache_insert_placeholder(const char *key, uint32_t key_length);
1411
Table *table_cache_insert_placeholder(const char *db_name, const char *table_name, const char *key, uint32_t key_length);
1420
1412
bool lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table);
1421
1413
bool lock_table_name_if_not_cached(const char *db,
1422
1414
const char *table_name, Table **table);
1424
typedef drizzled::hash_map<std::string, message::Table> TableMessageCache;
1416
typedef unordered_map<std::string, message::Table> TableMessageCache;
1425
1417
TableMessageCache table_message_cache;
1427
bool storeTableMessage(TableIdentifier &identifier, message::Table &table_message);
1428
bool removeTableMessage(TableIdentifier &identifier);
1429
bool getTableMessage(TableIdentifier &identifier, message::Table &table_message);
1430
bool doesTableMessageExist(TableIdentifier &identifier);
1431
bool renameTableMessage(TableIdentifier &from, TableIdentifier &to);
1419
bool storeTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1420
bool removeTableMessage(const TableIdentifier &identifier);
1421
bool getTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1422
bool doesTableMessageExist(const TableIdentifier &identifier);
1423
bool renameTableMessage(const TableIdentifier &from, const TableIdentifier &to);
1433
1425
/* Work with temporary tables */
1434
1426
Table *find_temporary_table(TableList *table_list);
1436
1428
Table *find_temporary_table(TableIdentifier &identifier);
1438
1430
void doGetTableNames(CachedDirectory &directory,
1439
SchemaIdentifier &schema_identifier,
1431
const SchemaIdentifier &schema_identifier,
1440
1432
std::set<std::string>& set_of_names);
1441
void doGetTableNames(SchemaIdentifier &schema_identifier,
1433
void doGetTableNames(const SchemaIdentifier &schema_identifier,
1442
1434
std::set<std::string>& set_of_names);
1444
1436
void doGetTableIdentifiers(CachedDirectory &directory,
1445
SchemaIdentifier &schema_identifier,
1437
const SchemaIdentifier &schema_identifier,
1446
1438
TableIdentifiers &set_of_identifiers);
1447
void doGetTableIdentifiers(SchemaIdentifier &schema_identifier,
1439
void doGetTableIdentifiers(const SchemaIdentifier &schema_identifier,
1448
1440
TableIdentifiers &set_of_identifiers);
1450
int doGetTableDefinition(drizzled::TableIdentifier &identifier,
1442
int doGetTableDefinition(const drizzled::TableIdentifier &identifier,
1451
1443
message::Table &table_proto);
1452
bool doDoesTableExist(TableIdentifier &identifier);
1444
bool doDoesTableExist(const drizzled::TableIdentifier &identifier);
1454
1446
void close_temporary_tables();
1455
1447
void close_temporary_table(Table *table);
1462
1454
void dumpTemporaryTableNames(const char *id);
1463
1455
int drop_temporary_table(TableList *table_list);
1464
1456
bool rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier);
1465
bool rm_temporary_table(TableIdentifier &identifier);
1457
bool rm_temporary_table(TableIdentifier &identifier, bool best_effort= false);
1466
1458
Table *open_temporary_table(TableIdentifier &identifier,
1467
1459
bool link_in_list= true);
1475
1467
int setup_conds(TableList *leaves, COND **conds);
1476
1468
int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1470
Table *create_virtual_tmp_table(List<CreateField> &field_list);
1480
1475
Return the default storage engine
1494
1489
static void unlink(Session *session);
1491
void get_xid(DRIZZLE_XID *xid); // Innodb only
1494
std::vector<TableShareInstance *> temporary_shares;
1497
TableShareInstance *getTemporaryShare(TableIdentifier::Type type_arg);
1500
1502
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
1572
1574
static const std::bitset<CF_BIT_SIZE> CF_SHOW_TABLE_COMMAND(1 << CF_BIT_SHOW_TABLE_COMMAND);
1573
1575
static const std::bitset<CF_BIT_SIZE> CF_WRITE_LOGS_COMMAND(1 << CF_BIT_WRITE_LOGS_COMMAND);
1575
/* Functions in sql_class.cc */
1576
void add_to_status(system_status_var *to_var, system_status_var *from_var);
1578
void add_diff_to_status(system_status_var *to_var, system_status_var *from_var,
1579
system_status_var *dec_var);
1581
1577
} /* namespace drizzled */
1583
1579
#endif /* DRIZZLED_SESSION_H */