26
26
#include "drizzled/plugin.h"
27
27
#include <drizzled/sql_locale.h>
28
#include <drizzled/ha_trx_info.h>
28
#include "drizzled/resource_context.h"
29
29
#include <drizzled/cursor.h>
30
30
#include <drizzled/current_session.h>
31
31
#include <drizzled/sql_error.h>
177
179
bool log_warnings;
179
181
uint32_t optimizer_search_depth;
180
/* A bitmap for switching optimizations on/off */
181
uint32_t optimizer_switch;
182
182
uint32_t div_precincrement;
183
183
uint64_t preload_buff_size;
184
184
uint32_t read_buff_size;
316
0: Life time: one statement within a transaction. If @@autocommit is
317
on, also represents the entire transaction.
318
@sa trans_register_ha()
320
1: Life time: one transaction within a connection.
321
If the storage engine does not participate in a transaction,
322
this should not be used.
323
@sa trans_register_ha()
325
Ha_trx_info ha_info[2];
316
* Resource contexts for both the "statement" and "normal"
319
* Resource context at index 0:
321
* Life time: one statement within a transaction. If @@autocommit is
322
* on, also represents the entire transaction.
324
* Resource context at index 1:
326
* Life time: one transaction within a connection.
330
* If the storage engine does not participate in a transaction,
331
* there will not be a resource context.
333
drizzled::ResourceContext resource_context[2];
327
335
Ha_data() :ha_ptr(NULL) {}
409
417
LEX *lex; /**< parse tree descriptor */
411
Points to the query associated with this statement. It's const, but
412
we need to declare it char * because all table handlers are written
413
in C and need to point to it.
415
Note that (A) if we set query = NULL, we must at the same time set
416
query_length = 0, and protect the whole operation with the
417
LOCK_thread_count mutex. And (B) we are ONLY allowed to set query to a
418
non-NULL value if its previous value is NULL. We do not need to protect
419
operation (B) with any mutex. To avoid crashes in races, if we do not
420
know that session->query cannot change at the moment, one should print
421
session->query like this:
422
(1) reserve the LOCK_thread_count mutex;
423
(2) check if session->query is NULL;
424
(3) if not NULL, then print at most session->query_length characters from
425
it. We will see the query_length field as either 0, or the right value
427
Assuming that the write and read of an n-bit memory field in an n-bit
428
computer is atomic, we can avoid races in the above way.
429
This printing is needed at least in SHOW PROCESSLIST and SHOW INNODB
433
uint32_t query_length; /**< current query length */
418
/** query associated with this statement */
436
422
Name of the current (default) database.
480
466
char *thread_stack;
469
SecurityContext security_ctx;
471
const SecurityContext& getSecurityContext() const
476
SecurityContext& getSecurityContext()
484
Some members of Session (currently 'Statement::db',
485
'query') are set and alloced by the slave SQL thread
486
(for the Session of that thread); that thread is (and must remain, for now)
487
the only responsible for freeing these 3 members. If you add members
488
here, and you add code to set them in replication, don't forget to
489
free_them_and_set_them_to_0 in replication properly. For details see
490
the 'err:' label of the handle_slave_sql() in sql/slave.cc.
492
@see handle_slave_sql
494
Security_context security_ctx;
482
* Is this session viewable by the current user?
484
bool isViewable() const
486
return plugin::Authorization::isAuthorized(current_session->getSecurityContext(),
497
492
Used in error messages to tell user in what part of MySQL we found an
531
526
/* container for handler's private per-connection data */
532
Ha_data ha_data[MAX_HA];
527
std::vector<Ha_data> ha_data;
534
529
Id of current query. Statement can be reused to execute several queries
535
530
query_id is global in context of the whole MySQL server.
541
536
query_id_t query_id;
542
537
query_id_t warn_query_id;
544
void **getEngineData(const plugin::StorageEngine *engine);
545
Ha_trx_info *getEngineInfo(const plugin::StorageEngine *engine,
539
void **getEngineData(const plugin::MonitoredInTransaction *monitored);
540
ResourceContext *getResourceContext(const plugin::MonitoredInTransaction *monitored,
548
543
struct st_transactions {
549
std::deque<drizzled::NamedSavepoint> savepoints;
550
Session_TRANS all; // Trans since BEGIN WORK
551
Session_TRANS stmt; // Trans for current statement
544
std::deque<NamedSavepoint> savepoints;
545
TransactionContext all; ///< Trans since BEGIN WORK
546
TransactionContext stmt; ///< Trans for current statement
552
547
XID_STATE xid_state;
555
Tables changed in transaction (that must be invalidated in query cache).
556
List contain only transactional tables, that not invalidated in query
557
cache (instead of full list of changed in transaction tables).
561
551
savepoints.clear();
1042
1033
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1043
1034
const char* str, uint32_t length,
1044
1035
bool allocate_lex_string);
1036
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1037
const std::string &str,
1038
bool allocate_lex_string);
1046
1040
int send_explain_fields(select_result *result);
1428
1422
/* Work with temporary tables */
1429
1423
Table *find_temporary_table(TableList *table_list);
1430
1424
Table *find_temporary_table(const char *db, const char *table_name);
1425
void doGetTableNames(CachedDirectory &directory,
1426
const std::string& db_name,
1427
std::set<std::string>& set_of_names);
1428
int doGetTableDefinition(const char *path,
1430
const char *table_name,
1432
message::Table *table_proto);
1432
1434
void close_temporary_tables();
1433
1435
void close_temporary_table(Table *table);
1440
1442
int drop_temporary_table(TableList *table_list);
1441
1443
bool rm_temporary_table(plugin::StorageEngine *base, const char *path);
1442
bool rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier);
1444
bool rm_temporary_table(TableIdentifier &identifier);
1443
1445
Table *open_temporary_table(TableIdentifier &identifier,
1444
1446
bool link_in_list= true);
1550
1552
static const std::bitset<CF_BIT_SIZE> CF_WRITE_LOGS_COMMAND(1 << CF_BIT_WRITE_LOGS_COMMAND);
1552
1554
/* Functions in sql_class.cc */
1553
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
1555
void add_to_status(system_status_var *to_var, system_status_var *from_var);
1555
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
1556
STATUS_VAR *dec_var);
1557
void add_diff_to_status(system_status_var *to_var, system_status_var *from_var,
1558
system_status_var *dec_var);
1558
1560
} /* namespace drizzled */