#include <session.h>


Classes | |
| struct | st_transactions |
Public Types | |
| enum | killed_state { NOT_KILLED, KILL_BAD_DATA, KILL_CONNECTION, KILL_QUERY, KILLED_NO_VALUE } |
Public Member Functions | |
| void * | alloc (size_t size) |
| void * | calloc (size_t size) |
| char * | strdup (const char *str) |
| char * | strmake (const char *str, size_t size) |
| void * | memdup (const void *str, size_t size) |
| void * | memdup_w_gap (const void *str, size_t size, uint32_t gap) |
| void | free_items () |
| void ** | getEngineData (const drizzled::plugin::StorageEngine *engine) |
| Ha_trx_info * | getEngineInfo (const drizzled::plugin::StorageEngine *engine, size_t index=0) |
| void | set_proc_info (const char *info) |
| const char * | get_proc_info () const |
| query_id_t | getQueryId () const |
| const char * | getQueryString () const |
| size_t | getQueryLength () const |
| uint64_t | getSessionId () const |
| uint32_t | getServerId () const |
| my_xid | getTransactionId () |
| void | record_first_successful_insert_id_in_cur_stmt (uint64_t id_arg) |
| uint64_t | read_first_successful_insert_id_in_prev_stmt (void) |
| void | force_one_auto_inc_interval (uint64_t next_id) |
| Session (drizzled::plugin::Client *client_arg) | |
| void | cleanup (void) |
| void | cleanup_after_query () |
| bool | storeGlobals () |
| void | awake (Session::killed_state state_to_set) |
| bool | initGlobals () |
| void | prepareForQueries () |
| bool | executeStatement () |
| bool | readAndStoreQuery (const char *in_packet, uint32_t in_packet_length) |
| bool | endTransaction (enum enum_mysql_completiontype completion) |
| bool | endActiveTransaction () |
| bool | startTransaction (start_transaction_option_t opt=START_TRANS_NO_OPTIONS) |
| bool | authenticate () |
| void | run () |
| bool | schedule () |
| const char * | enter_cond (pthread_cond_t *cond, pthread_mutex_t *mutex, const char *msg) |
| void | exit_cond (const char *old_msg) |
| time_t | query_start () |
| void | set_time () |
| void | set_current_time () |
| void | set_time (time_t t) |
| void | set_time_after_lock () |
| uint64_t | getCurrentTimestamp () |
| uint64_t | found_rows (void) |
| bool | inTransaction () |
| bool | fill_derived_tables () |
| void * | trans_alloc (unsigned int size) |
| LEX_STRING * | make_lex_string (LEX_STRING *lex_str, const char *str, uint32_t length, bool allocate_lex_string) |
| void | add_changed_table (Table *table) |
| void | add_changed_table (const char *key, long key_length) |
| CHANGED_TableList * | changed_table_dup (const char *key, long key_length) |
| int | send_explain_fields (select_result *result) |
| void | clear_error () |
| void | fatal_error () |
| bool | is_error () const |
| const CHARSET_INFO * | charset () |
| void | change_item_tree (Item **place, Item *new_value) |
| void | end_statement () |
| int | killed_errno () const |
| void | send_kill_message () const |
| bool | really_abort_on_warning () |
| void | set_status_var_init () |
| void | reset_n_backup_open_tables_state (Open_tables_state *backup) |
| void | restore_backup_open_tables_state (Open_tables_state *backup) |
| bool | set_db (const NormalisedDatabaseName &new_db) |
| void | clear_db () |
| bool | copy_db_to (char **p_db, size_t *p_db_length) |
| void | push_internal_handler (Internal_error_handler *handler) |
| virtual bool | handle_error (uint32_t sql_errno, const char *message, DRIZZLE_ERROR::enum_warning_level level) |
| void | pop_internal_handler () |
| void | reset_for_next_command () |
| void | disconnect (uint32_t errcode, bool lock) |
| bool | checkUser (const char *passwd, uint32_t passwd_len, const char *db) |
| uint64_t | getConnectMicroseconds () const |
| drizzled::message::Transaction * | getTransactionMessage () const |
| drizzled::message::Statement * | getStatementMessage () const |
| void | setTransactionMessage (drizzled::message::Transaction *in_message) |
| void | setStatementMessage (drizzled::message::Statement *in_message) |
| void | my_ok (ha_rows affected_rows=0, ha_rows found_rows_arg=0, uint64_t passed_id=0, const char *message=NULL) |
| void | my_eof () |
| bool | add_item_to_list (Item *item) |
| bool | add_value_to_list (Item *value) |
| bool | add_order_to_list (Item *item, bool asc) |
| bool | add_group_to_list (Item *item, bool asc) |
| void | refresh_status () |
| user_var_entry * | getVariable (LEX_STRING &name, bool create_if_not_exists) |
| void | close_thread_tables () |
| void | close_old_data_files (bool morph_locks=false, bool send_refresh=false) |
| void | close_open_tables () |
| void | close_data_files_and_morph_locks (const char *db, const char *table_name) |
| void | close_tables_for_reopen (TableList **tables) |
| bool | openTablesLock (TableList *tables) |
| bool | openTables (TableList *tables, uint32_t flags=0) |
| int | open_tables_from_list (TableList **start, uint32_t *counter, uint32_t flags=0) |
| Table * | openTableLock (TableList *table_list, thr_lock_type lock_type) |
| Table * | openTable (TableList *table_list, bool *refresh, uint32_t flags=0) |
| void | unlink_open_table (Table *find) |
| void | drop_open_table (Table *table, const char *db_name, const char *table_name) |
| void | close_cached_table (Table *table) |
| Table * | table_cache_insert_placeholder (const char *key, uint32_t key_length) |
| bool | lock_table_name_if_not_cached (const char *db, const char *table_name, Table **table) |
| Table * | find_temporary_table (TableList *table_list) |
| Table * | find_temporary_table (const char *db, const char *table_name) |
| void | close_temporary_tables () |
| void | close_temporary_table (Table *table) |
| int | drop_temporary_table (TableList *table_list) |
| bool | rm_temporary_table (drizzled::plugin::StorageEngine *base, const char *path) |
| bool | rm_temporary_table (drizzled::plugin::StorageEngine *base, drizzled::TableIdentifier &identifier) |
| Table * | open_temporary_table (drizzled::TableIdentifier &identifier, bool link_in_list=true) |
| bool | reopen_tables (bool get_locks, bool mark_share_as_old) |
| bool | reopen_name_locked_table (TableList *table_list, bool link_in) |
| bool | close_cached_tables (TableList *tables, bool wait_for_refresh, bool wait_for_placeholders) |
| void | wait_for_condition (pthread_mutex_t *mutex, pthread_cond_t *cond) |
| int | setup_conds (TableList *leaves, COND **conds) |
| int | lock_tables (TableList *tables, uint32_t count, bool *need_reopen) |
| drizzled::plugin::StorageEngine * | getDefaultStorageEngine () |
| void | set_open_tables_state (Open_tables_state *state) |
| void | reset_open_tables_state () |
Static Public Member Functions | |
| static void | unlink (Session *session) |
Public Attributes | |
| enum enum_mark_columns | mark_used_columns |
| Item * | free_list |
| drizzled::memory::Root * | mem_root |
| uint32_t | id |
| LEX * | lex |
| char * | query |
| uint32_t | query_length |
| std::string | db |
| drizzled::memory::Root | warn_root |
| drizzled::plugin::Client * | client |
| drizzled::plugin::Scheduler * | scheduler |
| void * | scheduler_arg |
| HASH | user_vars |
| struct system_variables | variables |
| struct system_status_var | status_var |
| struct system_status_var * | initial_status_var |
| THR_LOCK_INFO | lock_info |
| THR_LOCK_OWNER | main_lock_id |
| THR_LOCK_OWNER * | lock_id |
| pthread_mutex_t | LOCK_delete |
| char | process_list_info [PROCESS_LIST_WIDTH+1] |
| char * | thread_stack |
| Security_context | security_ctx |
| const char * | where |
| uint32_t | dbug_sentry |
| struct st_my_thread_var * | mysys_var |
| enum enum_server_command | command |
| uint32_t | file_id |
| uint32_t | max_client_packet_length |
| time_t | start_time |
| time_t | user_time |
| uint64_t | thr_create_utime |
| uint64_t | start_utime |
| uint64_t | utime_after_lock |
| thr_lock_type | update_lock_default |
| void * | replication_data |
| struct Session::st_transactions | transaction |
| Field * | dup_field |
| sigset_t | signals |
| bool | arg_of_last_insert_id_function |
| uint64_t | first_successful_insert_id_in_prev_stmt |
| uint64_t | first_successful_insert_id_in_cur_stmt |
| Discrete_intervals_list | auto_inc_intervals_in_cur_stmt_for_binlog |
| Discrete_intervals_list | auto_inc_intervals_forced |
| uint64_t | limit_found_rows |
| uint64_t | options |
| int64_t | row_count_func |
| ha_rows | cuted_fields |
| ha_rows | sent_row_count |
| ha_rows | examined_row_count |
| table_map | used_tables |
| List< DRIZZLE_ERROR > | warn_list |
| uint32_t | warn_count [(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END] |
| uint32_t | total_warn_count |
| Diagnostics_area | main_da |
| query_id_t | query_id |
| query_id_t | warn_id |
| ulong | col_access |
| uint32_t | statement_id_counter |
| uint32_t | rand_saved_seed1 |
| uint32_t | rand_saved_seed2 |
| uint32_t | row_count |
| pthread_t | real_id |
| uint64_t | thread_id |
| uint32_t | tmp_table |
| uint32_t | global_read_lock |
| uint32_t | server_status |
| uint32_t | open_options |
| uint32_t | select_number |
| enum_tx_isolation | session_tx_isolation |
| enum_check_fields | count_cuted_fields |
| killed_state volatile | killed |
| bool | some_tables_deleted |
| bool | no_errors |
| bool | password |
| bool | is_fatal_error |
| bool | transaction_rollback_request |
| bool | is_fatal_sub_stmt_error |
| bool | substitute_null_with_insert_id |
| bool | cleanup_done |
| bool | abort_on_warning |
| bool | got_warning |
| bool | no_warnings_for_error |
| bool | derived_tables_processing |
| bool | tablespace_op |
| union { | |
| bool bool_value | |
| uint32_t uint32_t_value | |
| int32_t int32_t_value | |
| uint64_t uint64_t_value | |
| } | sys_var_tmp |
| Lex_input_stream * | m_lip |
| void * | session_marker |
| Table * | cached_table |
| Table * | open_tables |
| Table * | temporary_tables |
| Table * | derived_tables |
| DRIZZLE_LOCK * | lock |
| DRIZZLE_LOCK * | extra_lock |
| uint64_t | version |
| uint32_t | current_tablenr |
| bool | backups_available |
Static Public Attributes | |
| static const char *const | DEFAULT_WHERE = "field list" |
Private Member Functions | |
| void | mark_used_tables_as_free_for_reuse (Table *table) |
| void | mark_temp_tables_as_free_for_reuse () |
| bool | free_cached_table () |
| void | close_temporary (Table *table) |
Private Attributes | |
| Ha_data | ha_data [MAX_HA] |
| drizzled::message::Transaction * | transaction_message |
| drizzled::message::Statement * | statement_message |
| uint64_t | connect_microseconds |
| const char * | proc_info |
| Internal_error_handler * | m_internal_handler |
| LEX | main_lex |
| drizzled::memory::Root | main_mem_root |
Contains the client/server protocol object, the current statement being executed, local-to-session variables and status counters, and a host of other information.
The Session class should have a vector of Statement object pointers which comprise the statements executed on the Session. Until this architectural change is done, we can forget about parallel operations inside a session.
Make member variables private and have inlined accessors and setters. Hide all member variables that are not critical to non-internal operations of the session object.
Definition at line 342 of file session.h.
| bool Session::authenticate | ( | void | ) |
Authenticates users, with error reporting.
Returns true on success, or false on failure.
Definition at line 668 of file session.cc.
References drizzled::plugin::Client::authenticate(), and client.
Referenced by run().


| bool Session::checkUser | ( | const char * | passwd, | |
| uint32_t | passwd_len, | |||
| const char * | db | |||
| ) |
Check if user exists and the password supplied is correct.
Returns true on success, and false on failure.
| Scrambled | password received from client | |
| Length | of scrambled password | |
| Database | name to connect to, may be NULL |
Definition at line 678 of file session.cc.
References Security_context::ip, my_ok(), security_ctx, Security_context::skip_grants(), and Security_context::user.

| void Session::cleanup_after_query | ( | ) |
Cleans up after query.
This function is used to reset thread data to its default state.
This function is not suitable for setting thread data to some non-default values, as there is only one replication thread, so different master threads may overwrite data of each other on slave.
Definition at line 885 of file session.cc.
References auto_inc_intervals_in_cur_stmt_for_binlog, DEFAULT_WHERE, first_successful_insert_id_in_cur_stmt, first_successful_insert_id_in_prev_stmt, free_items(), substitute_null_with_insert_id, and where.
Referenced by mysql_parse().


| void Session::clear_error | ( | ) | [inline] |
Clear the current error, if any. We do not clear is_fatal_error or is_fatal_sub_stmt_error since we assume this is never called if the fatal error is set.
Definition at line 1044 of file session.h.
References Diagnostics_area::is_error(), and Diagnostics_area::reset_diagnostics_area().
Referenced by executeStatement(), drizzled::plugin::InfoSchemaMethods::fillTable(), mysql_checksum_table(), and reset_for_next_command().


| void Session::close_tables_for_reopen | ( | TableList ** | tables | ) |
Prepares statement for reopening of tables and recalculation of set of prelocked tables.
| Pointer | to a pointer to a list of tables which we were trying to open and lock |
Definition at line 2104 of file session.cc.
References close_thread_tables(), lex, and TableList::next_global.
Referenced by drizzled::plugin::InfoSchemaMethods::fillTable(), and openTablesLock().


| void Session::close_thread_tables | ( | ) |
Closes all tables used by the current substatement, or all tables used by this thread if we are on the upper level.
Definition at line 2029 of file session.cc.
References Diagnostics_area::can_overwrite_status, close_open_tables(), Table::free_tmp_table(), is_error(), mark_temp_tables_as_free_for_reuse(), Table::next, and Open_tables_state::open_tables.
Referenced by close_tables_for_reopen(), dispatch_command(), and mysql_checksum_table().


| void Session::disconnect | ( | uint32_t | errcode, | |
| bool | lock | |||
| ) |
Disconnects the session from a client connection and updates any status variables necessary.
| errcode | Error code to print to console | |
| should_lock | 1 if we have have to lock LOCK_thread_count |
Definition at line 1803 of file session.cc.
References client, drizzled::plugin::Client::close(), db, Security_context::ip, Diagnostics_area::is_error(), drizzled::plugin::Client::isConnected(), Diagnostics_area::message(), security_ctx, drizzled::plugin::Client::sendError(), Security_context::user, variables, and drizzled::plugin::Client::wasAborted().
Referenced by SingleThreadScheduler::addSession(), initGlobals(), and run().


| void Session::end_statement | ( | ) |
Cleanup statement parse state (parse tree, lex) and execution state after execution of a non-prepared SQL statement.
Move this to Statement::~Statement
Definition at line 1644 of file session.cc.
References lex.
Referenced by mysql_parse().

| bool Session::endTransaction | ( | enum enum_mysql_completiontype | completion | ) |
Ends the current transaction and (maybe) begins the next.
Returns true if the transaction completed successfully, otherwise false.
| Completion | type |
Definition at line 780 of file session.cc.
References options.
| bool Session::executeStatement | ( | ) |
Executes a single statement received from the client connection.
Returns true if the statement was successful, or false otherwise.
In MySQL, this used to be the do_command() C function whic accepted a single parameter of the THD pointer.
Definition at line 722 of file session.cc.
References clear_error(), client, command, dispatch_command(), lex, drizzled::plugin::Client::readCommand(), and Diagnostics_area::reset_diagnostics_area().
Referenced by run().


| void Session::fatal_error | ( | ) | [inline] |
Mark the current error as fatal. Warning: this does not set any error, it sets a property of the error, so must be followed or prefixed with my_error().
Definition at line 1056 of file session.h.
References Diagnostics_area::is_error(), and is_fatal_error.

| void Session::force_one_auto_inc_interval | ( | uint64_t | next_id | ) | [inline] |
Used by Intvar_log_event::do_apply_event() and by "SET INSERT_ID=#" (mysqlbinlog). We'll soon add a variant which can take many intervals in argument.
Definition at line 869 of file session.h.
References auto_inc_intervals_forced.
| void Session::free_items | ( | ) |
Frees all items attached to this Statement
Definition at line 282 of file session.cc.
References Item::delete_self(), free_list, and Item::next.
Referenced by cleanup_after_query().


| uint64_t Session::getConnectMicroseconds | ( | ) | const [inline] |
Returns the timestamp (in microseconds) of when the Session connected to the server.
Definition at line 1203 of file session.h.
References connect_microseconds.
| uint64_t Session::getCurrentTimestamp | ( | ) | [inline] |
| drizzled::plugin::StorageEngine* Session::getDefaultStorageEngine | ( | ) | [inline] |
Return the default storage engine
| getDefaultStorageEngine() |
Definition at line 1456 of file session.h.
References variables.
| query_id_t Session::getQueryId | ( | ) | const [inline] |
Returns the current query ID
Definition at line 781 of file session.h.
Referenced by innobase_mysql_print_thd().

| size_t Session::getQueryLength | ( | ) | const [inline] |
| const char* Session::getQueryString | ( | ) | const [inline] |
Returns the current query text
Definition at line 787 of file session.h.
References query.
Referenced by innobase_mysql_print_thd().

| uint32_t Session::getServerId | ( | ) | const [inline] |
| uint64_t Session::getSessionId | ( | ) | const [inline] |
| drizzled::message::Statement* Session::getStatementMessage | ( | ) | const [inline] |
Returns a pointer to the active Statement message for this Session, or NULL if no active message.
Definition at line 1222 of file session.h.
Referenced by drizzled::ReplicationServices::commitTransaction(), drizzled::ReplicationServices::getDeleteStatement(), drizzled::ReplicationServices::getInsertStatement(), and drizzled::ReplicationServices::getUpdateStatement().

| my_xid Session::getTransactionId | ( | ) | [inline] |
| drizzled::message::Transaction* Session::getTransactionMessage | ( | ) | const [inline] |
Returns a pointer to the active Transaction message for this Session being managed by the ReplicationServices component, or NULL if no active message.
Definition at line 1213 of file session.h.
References transaction_message.
Referenced by drizzled::ReplicationServices::getActiveTransaction().

| bool Session::handle_error | ( | uint32_t | sql_errno, | |
| const char * | message, | |||
| DRIZZLE_ERROR::enum_warning_level | level | |||
| ) | [virtual] |
Handle an error condition.
| sql_errno | the error number | |
| level | the error level |
Definition at line 303 of file session.cc.
References Internal_error_handler::handle_error(), and m_internal_handler.

| bool Session::initGlobals | ( | ) |
Pulls thread-specific variables into Session state.
Returns true most times, or false if there was a problem allocating resources for thread-specific storage.
Kill this. It's not necessary once my_thr_init() is bye bye.
Definition at line 573 of file session.cc.
References disconnect().
Referenced by run().


| bool Session::inTransaction | ( | ) | [inline] |
| bool Session::is_error | ( | ) | const [inline] |
true if there is an error in the error stack.
Please use this method instead of direct access to net.report_error.
If true, the current (sub)-statement should be aborted. The main difference between this member and is_fatal_error is that a fatal error can not be handled by a stored procedure continue handler, whereas a normal error can.
To raise this flag, use my_error().
Definition at line 1074 of file session.h.
References Diagnostics_area::is_error().
Referenced by drizzled::alter_table(), close_thread_tables(), dispatch_command(), drizzled::plugin::InfoSchemaMethods::fillTable(), find_all_keys(), handle_select(), mysql_execute_command(), mysql_parse(), mysql_select(), and parse_sql().


| LEX_STRING * Session::make_lex_string | ( | LEX_STRING * | lex_str, | |
| const char * | str, | |||
| uint32_t | length, | |||
| bool | allocate_lex_string | |||
| ) |
Create a LEX_STRING in this connection.
| lex_str | pointer to LEX_STRING object to be initialized | |
| str | initializer to be copied into lex_str | |
| length | length of str, in bytes | |
| allocate_lex_string | if true, allocate new LEX_STRING object, instead of using lex_str value |
Definition at line 919 of file session.cc.
References mem_root.
Referenced by drizzled::plugin::InfoSchemaMethods::fillTable(), and ha_innobase::get_foreign_key_list().

| void Session::mark_temp_tables_as_free_for_reuse | ( | ) | [private] |
Mark all temporary tables which were used by the current statement or substatement as free for reuse, but only if the query_id can be cleared.
| session | thread context |
Definition at line 1996 of file session.cc.
References Table::cursor, Cursor::ha_reset(), Table::next, Table::query_id, and Open_tables_state::temporary_tables.
Referenced by close_thread_tables().


| void Session::mark_used_tables_as_free_for_reuse | ( | Table * | table | ) | [private] |
Marks all tables in the list which were used by current substatement as free for reuse.
| Head | of the list of tables |
For example
SELECT f1_that_uses_t1() FROM t1;
In f1_that_uses_t1() we will see one instance of t1 where query_id is set to query_id of original query.
Definition at line 2008 of file session.cc.
References Table::cursor, Cursor::ha_reset(), Table::next, and Table::query_id.

| void Session::my_eof | ( | ) | [inline] |
A short cut for session->main_da.set_eof_status().
Definition at line 1317 of file session.h.
References Diagnostics_area::set_eof_status().
Referenced by dispatch_command(), and mysql_checksum_table().


| void Session::my_ok | ( | ha_rows | affected_rows = 0, |
|
| ha_rows | found_rows_arg = 0, |
|||
| uint64_t | passed_id = 0, |
|||
| const char * | message = NULL | |||
| ) | [inline] |
A short cut for session->main_da.set_ok_status().
Definition at line 1308 of file session.h.
References Diagnostics_area::set_ok_status().
Referenced by drizzled::alter_table(), checkUser(), dispatch_command(), and drizzled::mysql_rm_table().


| bool Session::openTables | ( | TableList * | tables, | |
| uint32_t | flags = 0 | |||
| ) |
Open all tables in list and process derived tables
| Pointer | to a list of tables for open | |
| Bitmap | of flags to modify how the tables will be open: DRIZZLE_LOCK_IGNORE_FLUSH - open table even if someone has done a flush or namelock on it. |
| false | - ok | |
| true | - error |
Definition at line 2142 of file session.cc.
References lex.
Referenced by drizzled::plugin::InfoSchemaMethods::fillTable().

| bool Session::openTablesLock | ( | TableList * | tables | ) |
Open all tables in list, locks them (all, including derived)
| Pointer | to a list of tables for open & locking |
| false | - ok | |
| true | - error |
Definition at line 2118 of file session.cc.
References close_tables_for_reopen(), and lex.

| void Session::pop_internal_handler | ( | ) |
Remove the error handler last pushed.
Definition at line 314 of file session.cc.
References m_internal_handler.
| void Session::prepareForQueries | ( | ) |
Initialize memory roots necessary for query processing and (!) pre-allocate memory for it. We can't do that in Session constructor because there are use cases where it's vital to not allocate excessive and not used memory.
Definition at line 553 of file session.cc.
References command, mem_root, options, set_proc_info(), and variables.
Referenced by run().


| void Session::push_internal_handler | ( | Internal_error_handler * | handler | ) |
Add an internal error handler to the thread execution context.
| handler | the exception handler to add |
Definition at line 293 of file session.cc.
References m_internal_handler.
| bool Session::readAndStoreQuery | ( | const char * | in_packet, | |
| uint32_t | in_packet_length | |||
| ) |
Reads a query from packet and stores it.
Returns true if query is read and allocated successfully, false otherwise. On a return of false, Session::fatal_error is set.
| The | packet pointer to read from | |
| The | length of the query to read |
Definition at line 752 of file session.cc.
References db, query, and query_length.
Referenced by dispatch_command().

| void Session::record_first_successful_insert_id_in_cur_stmt | ( | uint64_t | id_arg | ) | [inline] |
There is BUG#19630 where statement-based replication of stored functions/triggers with two auto_increment columns breaks. We however ensure that it works when there is 0 or 1 auto_increment column; our rules are a) on master, while executing a top statement involving substatements, first top- or sub- statement to generate auto_increment values wins the exclusive right to see its values be written to binlog (the write will be done by the statement or its caller), and the losers won't see their values be written to binlog. b) on slave, while replicating a top statement involving substatements, first top- or sub- statement to need to read auto_increment values from the master's binlog wins the exclusive right to read them (so the losers won't read their values from binlog but instead generate on their own). a) implies that we mustn't backup/restore auto_inc_intervals_in_cur_stmt_for_binlog. b) implies that we mustn't backup/restore auto_inc_intervals_forced.
If there are more than 1 auto_increment columns, then intervals for different columns may mix into the auto_inc_intervals_in_cur_stmt_for_binlog list, which is logically wrong, but there is no point in preventing this mixing by preventing intervals from the secondly inserted column to come into the list, as such prevention would be wrong too. What will happen in the case of INSERT INTO t1 (auto_inc) VALUES(NULL); where t1 has a trigger which inserts into an auto_inc column of t2, is that in binlog we'll store the interval of t1 and the interval of t2 (when we store intervals, soon), then in slave, t1 will use both intervals, t2 will use none; if t1 inserts the same number of rows as on master, normally the 2nd interval will not be used by t1, which is fine. t2's values will be wrong if t2's internal auto_increment counter is different from what it was on master (which is likely). In 5.1, in mixed binlogging mode, row-based binlogging is used for such cases where two auto_increment columns are inserted.
Definition at line 855 of file session.h.
References first_successful_insert_id_in_cur_stmt.
| void Session::reset_for_next_command | ( | ) |
Resets Session part responsible for command processing state.
This needs to be called before execution of every statement (prepared or conventional). It is not called by substatements of routines.
Call it after we use Session for queries, not before.
Definition at line 1844 of file session.cc.
References auto_inc_intervals_in_cur_stmt_for_binlog, clear_error(), examined_row_count, free_list, is_fatal_error, options, Diagnostics_area::reset_diagnostics_area(), select_number, and sent_row_count.
Referenced by mysql_parse().


| void Session::run | ( | ) |
Run a session.
This will initialize the session and begin the command loop.
Definition at line 584 of file session.cc.
References authenticate(), client, disconnect(), executeStatement(), drizzled::plugin::Client::haveError(), initGlobals(), and prepareForQueries().
Referenced by SingleThreadScheduler::addSession().


| bool Session::schedule | ( | ) |
Schedule a session to be run on the default scheduler.
Definition at line 603 of file session.cc.
References drizzled::plugin::Scheduler::addSession(), client, scheduler, drizzled::plugin::Client::sendError(), and variables.

| bool Session::set_db | ( | const NormalisedDatabaseName & | new_db | ) |
Set the current database; use deep copy of C-string.
| new_db | a pointer to the new database name. | |
| new_db_len | length of the new database name. |
| false | Success | |
| true | Out-of-memory error |
Definition at line 1733 of file session.cc.
References db.
| void Session::set_proc_info | ( | const char * | info | ) | [inline] |
Points to info-string that we show in SHOW PROCESSLIST You are supposed to call Session_SET_PROC_INFO only if you have coded a time-consuming piece that MySQL can get stuck in for a long time.
Set it using the session_proc_info(Session *thread, const char *message) macro/function.
Definition at line 771 of file session.h.
Referenced by drizzled::alter_table(), dispatch_command(), mysql_execute_command(), mysql_parse(), mysql_select(), and prepareForQueries().

| void Session::setStatementMessage | ( | drizzled::message::Statement * | in_message | ) | [inline] |
Sets the active statement message used by the ReplicationServices component.
| [in] | Pointer | to the message |
Definition at line 1244 of file session.h.
Referenced by drizzled::ReplicationServices::cleanupTransaction(), drizzled::ReplicationServices::getDeleteStatement(), drizzled::ReplicationServices::getInsertStatement(), and drizzled::ReplicationServices::getUpdateStatement().

| void Session::setTransactionMessage | ( | drizzled::message::Transaction * | in_message | ) | [inline] |
Sets the active transaction message used by the ReplicationServices component.
| [in] | Pointer | to the message |
Definition at line 1233 of file session.h.
References transaction_message.
Referenced by drizzled::ReplicationServices::cleanupTransaction(), and drizzled::ReplicationServices::getActiveTransaction().

| Discrete_intervals_list Session::auto_inc_intervals_forced |
Used by replication and SET INSERT_ID
Definition at line 615 of file session.h.
Referenced by force_one_auto_inc_interval().
| Discrete_intervals_list Session::auto_inc_intervals_in_cur_stmt_for_binlog |
We follow this logic:
List of auto_increment intervals reserved by the thread so far, for storage in the statement-based binlog. Note that its minimum is not first_successful_insert_id_in_cur_stmt: assuming a table with an autoinc column, and this happens: INSERT INTO ... VALUES(3); SET INSERT_ID=3; INSERT IGNORE ... VALUES (NULL); then the latter INSERT will insert no rows (first_successful_insert_id_in_cur_stmt == 0), but storing "INSERT_ID=3" in the binlog is still needed; the list's minimum will contain 3.
Definition at line 613 of file session.h.
Referenced by cleanup_after_query(), and reset_for_next_command().
Pointer to client object
Definition at line 451 of file session.h.
Referenced by authenticate(), disconnect(), dispatch_command(), executeStatement(), ProcessListISMethods::fillTable(), mysql_checksum_table(), run(), and schedule().
| enum enum_server_command Session::command |
Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from first byte of the packet in executeStatement()
Definition at line 507 of file session.h.
Referenced by dispatch_command(), executeStatement(), ProcessListISMethods::fillTable(), and prepareForQueries().
uint64_t Session::connect_microseconds [private] |
Microsecond timestamp of when Session connected
Definition at line 1253 of file session.h.
Referenced by getConnectMicroseconds().
| ha_rows Session::cuted_fields |
Count of "cut" or truncated fields.
Definition at line 620 of file session.h.
Referenced by drizzled::alter_table(), and store_val_in_field().
| std::string Session::db |
Name of the current (default) database.
If there is the current (default) database, "db" contains its name. If there is no current (default) database, "db" is NULL and "db_length" is 0. In other words, "db", "db_length" must either be NULL, or contain a valid database name.
Definition at line 440 of file session.h.
Referenced by disconnect(), dispatch_command(), ProcessListISMethods::fillTable(), mysql_parse(), drizzled::mysql_rm_table(), readAndStoreQuery(), and set_db().
| uint32_t Session::dbug_sentry |
const char *const Session::DEFAULT_WHERE = "field list" [static] |
Constant for Session::where initialization in the beginning of every query.
It's needed because we do not save/restore Session::where normally during primary (non subselect) query execution.
Definition at line 448 of file session.h.
Referenced by cleanup_after_query().
| ha_rows Session::examined_row_count |
Number of rows we read, sent or not, including in create_sort_index()
Definition at line 631 of file session.h.
Referenced by reset_for_next_command().
| uint32_t Session::file_id |
This is the first autogenerated insert id which was *successfully* inserted by the current statement. It is maintained only to set first_successful_insert_id_in_prev_stmt when statement ends.
Definition at line 585 of file session.h.
Referenced by cleanup_after_query(), and record_first_successful_insert_id_in_cur_stmt().
This is the first autogenerated insert id which was *successfully* inserted by the previous statement (exactly, if the previous statement didn't successfully insert an autogenerated insert id, then it's the one of the statement before, etc). It can also be set by SET LAST_INSERT_ID=# or SELECT LAST_INSERT_ID(#). It is returned by LAST_INSERT_ID().
Definition at line 579 of file session.h.
Referenced by cleanup_after_query(), and remove_eq_conds().
List of items created in the parser for this query. Every item puts itself to the list on creation (see Item::Item() for details))
Definition at line 393 of file session.h.
Referenced by free_items(), Item::Item(), and reset_for_next_command().
| bool Session::got_warning |
| uint32_t Session::id |
Set to true if execution of the current compound statement can not continue. In particular, disables activation of CONTINUE or EXIT handlers of stored routines. Reset in the end of processing of the current user request, in
Definition at line 709 of file session.h.
Referenced by add_ref_to_table_cond(), change_refs_to_tmp_fields(), fatal_error(), OpenTablesISMethods::fillTable(), find_order_in_list(), parse_sql(), and reset_for_next_command().
true if we are in a sub-statement and the current error can not be safely recovered until we left the sub-statement mode. In particular, disables activation of CONTINUE and EXIT handlers inside sub-statements. E.g. if it is a deadlock error and requires a transaction-wide rollback, this flag is raised (traditionally, MySQL first has to close all the reads via
| LEX* Session::lex |
parse tree descriptor
Definition at line 402 of file session.h.
Referenced by add_field_to_list(), Select_Lex::add_table_to_list(), build_equal_items_for_cond(), change_group_ref(), check_equality(), check_row_equality(), check_simple_select(), close_tables_for_reopen(), create_select_for_variable(), dispatch_command(), end_statement(), drizzled::statement::ShowStatus::execute(), executeStatement(), VariablesISMethods::fillTable(), StatusISMethods::fillTable(), OpenTablesISMethods::fillTable(), CharSetISMethods::fillTable(), drizzled::plugin::InfoSchemaMethods::fillTable(), CollationISMethods::fillTable(), get_lookup_field_values(), insert_precheck(), Item::Item(), mysql_execute_command(), mysql_parse(), mysql_select(), negate_expression(), openTables(), openTablesLock(), setup_group(), setup_without_group(), Item::split_sum_func(), update_precheck(), and update_ref_and_keys().
| pthread_mutex_t Session::LOCK_delete |
Locked before session is deleted
Definition at line 461 of file session.h.
Referenced by kill_one_thread().
| THR_LOCK_OWNER* Session::lock_id |
| THR_LOCK_INFO Session::lock_info |
The current internal error handler for this thread, or NULL.
Definition at line 1257 of file session.h.
Referenced by handle_error(), pop_internal_handler(), and push_internal_handler().
Character input stream consumed by the lexical analyser, used during parsing. Note that since the parser is not re-entrant, we keep only one input stream here. This member is valid only when executing code during parsing, and may point to invalid memory after that.
Definition at line 755 of file session.h.
Referenced by check_simple_select(), and parse_sql().
LEX Session::main_lex [private] |
The lex to hold the parsed tree of conventional (non-prepared) queries. Whereas for prepared and stored procedure statements we use an own lex instance for each new query, for conventional statements we reuse the same lex. (
| THR_LOCK_OWNER Session::main_lock_id |
drizzled::memory::Root Session::main_mem_root [private] |
This memory root is used for two purposes:
| uint32_t Session::max_client_packet_length |
| drizzled::memory::Root* Session::mem_root |
Pointer to current memroot
Definition at line 394 of file session.h.
Referenced by Create_func_abs::create(), Create_udf_func::create(), create_func_cast(), drizzled::ReplicationServices::deleteRecord(), dispatch_command(), drizzled::optimizer::QuickRangeSelect::init_ror_merged_scan(), drizzled::ReplicationServices::insertRecord(), make_lex_string(), prepareForQueries(), setup_copy_fields(), and drizzled::ReplicationServices::updateRecord().
no warnings on call to my_error()
Definition at line 734 of file session.h.
Referenced by drizzled::plugin::InfoSchemaMethods::fillTable().
Table* Open_tables_state::open_tables [inherited] |
List of regular tables in use by this thread. Contains temporary and base tables that were opened with
Definition at line 38 of file open_tables_state.h.
Referenced by close_data_files_and_morph_locks(), close_old_data_files(), close_open_tables(), close_thread_tables(), free_cached_table(), lock_table_name_if_not_cached(), reopen_tables(), and unlink_open_table().
| uint64_t Session::options |
Bitmap of options
Definition at line 618 of file session.h.
Referenced by endTransaction(), handle_select(), prepareForQueries(), remove_eq_conds(), and reset_for_next_command().
| char Session::process_list_info[PROCESS_LIST_WIDTH+1] |
A peek into the query string for the session. This is a best effort delivery, there is no guarantee whether the content is meaningful.
Definition at line 467 of file session.h.
Referenced by dispatch_command(), ProcessListISMethods::fillTable(), and mysql_execute_command().
| char* Session::query |
Points to the query associated with this statement. It's const, but we need to declare it char * because all table handlers are written in C and need to point to it.
Note that (A) if we set query = NULL, we must at the same time set query_length = 0, and protect the whole operation with the LOCK_thread_count mutex. And (B) we are ONLY allowed to set query to a non-NULL value if its previous value is NULL. We do not need to protect operation (B) with any mutex. To avoid crashes in races, if we do not know that session->query cannot change at the moment, one should print session->query like this: (1) reserve the LOCK_thread_count mutex; (2) check if session->query is NULL; (3) if not NULL, then print at most session->query_length characters from it. We will see the query_length field as either 0, or the right value for it. Assuming that the write and read of an n-bit memory field in an n-bit computer is atomic, we can avoid races in the above way. This printing is needed at least in SHOW PROCESSLIST and SHOW INNODB STATUS.
Definition at line 425 of file session.h.
Referenced by drizzled::alter_table(), dispatch_command(), getQueryLength(), getQueryString(), handle_select(), mysql_execute_command(), mysql_parse(), drizzled::mysql_prepare_alter_table(), parse_sql(), and readAndStoreQuery().
| uint32_t Session::query_length |
current query length
Definition at line 426 of file session.h.
Referenced by drizzled::alter_table(), dispatch_command(), mysql_execute_command(), mysql_parse(), and readAndStoreQuery().
| pthread_t Session::real_id |
| uint32_t Session::row_count |
Row counter, mainly for errors and warnings. Not increased in create_sort_index(); may differ from examined_row_count.
Definition at line 677 of file session.h.
Referenced by drizzled::alter_table().
| int64_t Session::row_count_func |
For the ROW_COUNT() function
Definition at line 619 of file session.h.
Referenced by mysql_execute_command().
| void* Session::scheduler_arg |
Pointer to the optional scheduler argument
Definition at line 453 of file session.h.
Referenced by PoolOfThreadsScheduler::addSession().
Definition at line 487 of file session.h.
Referenced by checkUser(), disconnect(), ProcessListISMethods::fillTable(), and innobase_mysql_print_thd().
| uint32_t Session::select_number |
number of select (used for EXPLAIN)
Definition at line 684 of file session.h.
Referenced by reset_for_next_command().
| ha_rows Session::sent_row_count |
Number of rows we actually sent to the client, including "synthetic" rows in ROLLUP etc.
Definition at line 626 of file session.h.
Referenced by reset_for_next_command().
| void* Session::session_marker |
Place to store various things
Definition at line 758 of file session.h.
Referenced by handle_select().
struct system_status_var Session::status_var [read] |
Session-local status counters
Definition at line 456 of file session.h.
Referenced by dispatch_command(), drizzled::statement::ShowStatus::execute(), filesort(), StatusISMethods::fillTable(), and mysql_execute_command().
for IS NULL => = last_insert_id() fix in remove_eq_conds()
Definition at line 729 of file session.h.
Referenced by cleanup_after_query(), and remove_eq_conds().
| union { ... } Session::sys_var_tmp |
Used by the sys_var class to store temporary values
Table* Open_tables_state::temporary_tables [inherited] |
List of temporary tables used by this thread. Contains user-level temporary tables, created with CREATE TEMPORARY TABLE, and internal temporary tables, created, e.g., to resolve a SELECT, or for an intermediate table used in ALTER. XXX Why are internal temporary tables added to this list?
Definition at line 46 of file open_tables_state.h.
Referenced by mark_temp_tables_as_free_for_reuse().
| uint64_t Session::thr_create_utime |
| char* Session::thread_stack |
A pointer to the stack frame of the scheduler thread which is called first in the thread for handling a client
Definition at line 473 of file session.h.
Referenced by SingleThreadScheduler::addSession().
drizzled::message::Transaction* Session::transaction_message [private] |
Pointers to memory managed by the ReplicationServices component
Definition at line 1250 of file session.h.
Referenced by getTransactionMessage(), and setTransactionMessage().
| table_map Session::used_tables |
The set of those tables whose fields are referenced in all subqueries of the query.
Possibly this it is incorrect to have used tables in Session because with more than one subquery, it is not clear what does the field mean.
Definition at line 642 of file session.h.
Referenced by mysql_select().
| HASH Session::user_vars |
struct system_variables Session::variables [read] |
Mutable local variables local to the session
Definition at line 455 of file session.h.
Referenced by best_access_path(), convert_constant_item(), disconnect(), field_conv(), filesort(), get_addon_fields(), get_date_from_str(), getDefaultStorageEngine(), drizzled::mysql_prepare_alter_table(), prepareForQueries(), drizzled::optimizer::QuickIndexMergeSelect::read_keys_and_merge(), Item::save_in_field_no_warnings(), schedule(), and sortlength().
| List<DRIZZLE_ERROR> Session::warn_list |
| drizzled::memory::Root Session::warn_root |
| const char* Session::where |
Used in error messages to tell user in what part of MySQL we found an error. E. g. when where= "having clause", if fix_fields() fails, user will know that the error was in having clause.
Definition at line 494 of file session.h.
Referenced by cleanup_after_query(), find_order_in_list(), handle_select(), setup_group(), and setup_order().
1.5.8