Drizzled Public API Documentation

drizzled::Session Class Reference

Classes

class  impl_c
 

Public Types

enum  global_read_lock_t { NONE = 0, GOT_GLOBAL_READ_LOCK = 1, MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT = 2 }
 
enum  killed_state_t {
  NOT_KILLED, KILL_BAD_DATA, KILL_CONNECTION, KILL_QUERY,
  KILLED_NO_VALUE
}
 
typedef boost::shared_ptr
< Session
shared_ptr
 
typedef boost::shared_ptr
< const std::string > 
QueryString
 
typedef boost::unordered_map
< std::string, user_var_entry
*, util::insensitive_hash,
util::insensitive_equal_to
UserVars
 

Public Member Functions

void free_items ()
 
uint64_t getXaId () const
 
void setXaId (uint64_t in_xa_id)
 
Diagnostics_areamain_da ()
 
const LEX & lex () const
 
LEX & lex ()
 
enum_sql_command getSqlCommand () const
 
void resetQueryString ()
 
const boost::shared_ptr
< session::State > & 
state ()
 
QueryString getQueryString () const
 
const char * getQueryStringCopy (size_t &length)
 
util::string::ptr schema () const
 
void setClient (plugin::Client *client_arg)
 
plugin::ClientgetClient () const
 
const UserVars & getUserVariables () const
 
enum_tx_isolation getTxIsolation () const
 
identifier::user::ptr user () const
 
void setUser (identifier::user::mptr arg)
 
int32_t getScoreboardIndex () const
 
void setScoreboardIndex (int32_t in_scoreboard_index)
 
bool isOriginatingServerUUIDSet () const
 
void setOriginatingServerUUID (std::string in_originating_server_uuid)
 
const std::string & getOriginatingServerUUID () const
 
void setOriginatingCommitID (uint64_t in_originating_commit_id)
 
uint64_t getOriginatingCommitID () const
 
bool isViewable (const identifier::User &) const
 
const char * where () const
 
void setWhere (const char *arg)
 
thread_ptr & getThread ()
 
void pushInterrupt (boost::this_thread::disable_interruption *interrupt_arg)
 
boost::this_thread::disable_interruption & getThreadInterupt ()
 
internal::st_my_thread_vargetThreadVar ()
 
void ** getEngineData (const plugin::MonitoredInTransaction *monitored)
 
ResourceContextgetResourceContext (const plugin::MonitoredInTransaction &, size_t index=0)
 
void setConcurrentExecute (bool arg)
 
bool isConcurrentExecuteAllowed () const
 
int64_t rowCount () const
 
global_read_lock_t isGlobalReadLock () const
 
void setGlobalReadLock (global_read_lock_t arg)
 
DrizzleLocklockTables (Table **tables, uint32_t count, uint32_t flags)
 
bool lockGlobalReadLock ()
 
bool lock_table_names (TableList *table_list)
 
bool lock_table_names_exclusively (TableList *table_list)
 
bool makeGlobalReadLockBlockCommit ()
 
bool abortLockForThread (Table *table)
 
bool wait_if_global_read_lock (bool abort_on_refresh, bool is_not_commit)
 
int lock_table_name (TableList *table_list)
 
void abortLock (Table *table)
 
void removeLock (Table *table)
 
void unlockReadTables (DrizzleLock *sql_lock)
 
void unlockSomeTables (Table **table, uint32_t count)
 
void unlockTables (DrizzleLock *sql_lock)
 
void startWaitingGlobalReadLock ()
 
void unlockGlobalReadLock ()
 
void setKilled (killed_state_t arg)
 
killed_state_t getKilled () const
 
volatile killed_state_t * getKilledPtr ()
 
bool doing_tablespace_operation () const
 
void setDoingTablespaceOperation (bool doing)
 
void set_proc_info (const char *info)
 
const char * get_proc_info () const
 
void setQueryId (query_id_t in_query_id)
 
query_id_t getQueryId () const
 
void setWarningQueryId (query_id_t in_query_id)
 
query_id_t getWarningQueryId () const
 
session_id_t getSessionId () const
 
uint32_t getServerId () const
 
std::string & getServerUUID () const
 
void record_first_successful_insert_id_in_cur_stmt (uint64_t id_arg)
 
uint64_t read_first_successful_insert_id_in_prev_stmt () const
 
 Session (plugin::Client *, boost::shared_ptr< catalog::Instance >)
 
void cleanup ()
 
void cleanup_after_query ()
 
void storeGlobals ()
 
void awake (Session::killed_state_t state_to_set)
 
void prepareForQueries ()
 
bool executeStatement ()
 
void readAndStoreQuery (str_ref)
 
bool endTransaction (enum enum_mysql_completiontype completion)
 
bool endActiveTransaction ()
 
bool startTransaction (start_transaction_option_t opt=START_TRANS_NO_OPTIONS)
 
void markTransactionForRollback (bool all)
 
bool authenticate ()
 
void run ()
 
const char * enter_cond (boost::condition_variable_any &cond, boost::mutex &mutex, const char *msg)
 
void exit_cond (const char *old_msg)
 
uint64_t found_rows () const
 
bool inTransaction () const
 
lex_string_tmake_lex_string (lex_string_t *, str_ref)
 
void send_explain_fields (select_result *)
 
void clear_error (bool full=false)
 
void clearDiagnostics ()
 
bool is_error () const
 
void end_statement ()
 
int killed_errno () const
 
void send_kill_message () const
 
bool abortOnWarning ()
 
void setAbortOnWarning (bool arg)
 
void setAbort (bool arg)
 
void lockOnSys ()
 
void set_status_var_init ()
 
void set_schema (const std::string &)
 
str_ref copy_db_to () const
 
void reset_for_next_command ()
 
void disconnect (enum error_t errcode=EE_OK)
 
bool checkUser (const std::string &passwd, const std::string &db)
 
message::TransactiongetTransactionMessage () const
 
message::StatementgetStatementMessage () const
 
message::ResultsetgetResultsetMessage () const
 
void setTransactionMessage (message::Transaction *in_message)
 
void setStatementMessage (message::Statement *in_message)
 
void setResultsetMessage (message::Resultset *in_message)
 
void resetResultsetMessage ()
 
plugin::EventObserverListgetSessionObservers ()
 
void setSessionObservers (plugin::EventObserverList *observers)
 
plugin::EventObserverListgetSchemaObservers (const std::string &schema)
 
plugin::EventObserverListsetSchemaObservers (const std::string &schema, plugin::EventObserverList *)
 
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 ()
 
void add_item_to_list (Item *item)
 
void add_value_to_list (Item *value)
 
void add_order_to_list (Item *item, bool asc)
 
void add_group_to_list (Item *item, bool asc)
 
void refresh_status ()
 
user_var_entrygetVariable (str_ref name, bool create_if_not_exists)
 
void setVariable (const std::string &name, const std::string &value)
 
void close_thread_tables ()
 
void close_old_data_files (bool morph_locks=false, bool send_refresh=false)
 
void close_data_files_and_morph_locks (const identifier::Table &)
 
void close_tables_for_reopen (TableList **tables)
 
bool openTablesLock (TableList *)
 
Tableopen_temporary_table (const identifier::Table &identifier, bool link_in_list=true)
 
int open_tables_from_list (TableList **start, uint32_t *counter, uint32_t flags=0)
 
TableopenTableLock (TableList *table_list, thr_lock_type lock_type)
 
TableopenTable (TableList *table_list, bool *refresh, uint32_t flags=0)
 
void unlink_open_table (Table *find)
 
void drop_open_table (Table *table, const identifier::Table &identifier)
 
void close_cached_table (Table *table)
 
table::Placeholdertable_cache_insert_placeholder (const identifier::Table &)
 
Tablelock_table_name_if_not_cached (const identifier::Table &)
 
session::TableMessagesgetMessageCache ()
 
bool reopen_tables ()
 
bool close_cached_tables (TableList *tables, bool wait_for_refresh, bool wait_for_placeholders)
 
void wait_for_condition (boost::mutex &mutex, boost::condition_variable_any &cond)
 
int setup_conds (TableList *leaves, COND **conds)
 
int lock_tables (TableList *tables, uint32_t count, bool *need_reopen)
 
template<class T >
T * getProperty (const std::string &name)
 
template<class T >
setProperty (const std::string &name, T value)
 
plugin::StorageEnginegetDefaultStorageEngine ()
 
void get_xid (DrizzleXid *xid) const
 
table::SingulargetInstanceTable ()
 
table::SingulargetInstanceTable (std::list< CreateField > &)
 
void setUsage (bool arg)
 
const rusage & getUsage ()
 
const catalog::Instancecatalog () const
 
catalog::Instancecatalog ()
 

Static Public Member Functions

static shared_ptr make_shared (plugin::Client *client, boost::shared_ptr< catalog::Instance > instance_arg)
 
static bool schedule (const Session::shared_ptr &)
 
static void unlink (session_id_t &)
 
static void unlink (const Session::shared_ptr &)
 
static const charset_info_stcharset ()
 

Public Attributes

enum_mark_columns mark_used_columns
 
Itemfree_list
 
memory::Rootmem
 
memory::Rootmem_root
 
memory::Root warn_root
 
plugin::Schedulerscheduler
 
drizzle_system_variablesvariables
 
system_status_varstatus_var
 
THR_LOCK_INFO lock_info
 
THR_LOCK_OWNER main_lock_id
 
THR_LOCK_OWNERlock_id
 
char * thread_stack
 
enum_server_command command
 
thr_lock_type update_lock_default
 
session::Transactionstransaction
 
Open_tables_stateopen_tables
 
session::Timestimes
 
Fielddup_field
 
sigset_t signals
 
uint64_t first_successful_insert_id_in_prev_stmt
 
uint64_t first_successful_insert_id_in_cur_stmt
 
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
 
uint32_t warn_count [(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END]
 
uint32_t total_warn_count
 
uint32_t row_count
 
session_id_t thread_id
 
uint32_t tmp_table
 
uint32_t server_status
 
uint32_t open_options
 
uint32_t select_number
 
enum_tx_isolation session_tx_isolation
 
enum_check_fields count_cuted_fields
 
bool is_admin_connection
 
bool no_errors
 
bool is_fatal_error
 
bool transaction_rollback_request
 
bool is_fatal_sub_stmt_error
 
bool substitute_null_with_insert_id
 
bool cleanup_done
 
bool got_warning
 
bool no_warnings_for_error
 
bool derived_tables_processing
 
union {
   bool   bool_value
 
   uint32_t   uint32_t_value
 
   int32_t   int32_t_value
 
   uint64_t   uint64_t_value
 
sys_var_tmp
 
Lex_input_streamm_lip
 
void * session_marker
 
bool arg_of_last_insert_id_function
 

Static Public Attributes

static const char *const DEFAULT_WHERE = "field list"
 

Private Types

typedef std::pair
< UserVars::iterator,
UserVars::iterator > 
UserVarsRange
 

Private Member Functions

int unlock_external (Table **table, uint32_t count)
 
int lock_external (Table **tables, uint32_t count)
 
bool wait_for_locked_table_names (TableList *table_list)
 
DrizzleLockget_lock_data (Table **table_ptr, uint32_t count, bool should_lock, Table **write_lock_used)
 
drizzled::util::StorablegetProperty0 (const std::string &)
 
void setProperty0 (const std::string &, drizzled::util::Storable *)
 
bool resetUsage ()
 

Private Attributes

boost::scoped_ptr< impl_cimpl_
 
boost::shared_ptr< std::string > query
 
UserVars user_vars
 
const char * _where
 
boost::thread::id boost_thread_id
 
thread_ptr _thread
 
boost::this_thread::disable_interruption * interrupt
 
internal::st_my_thread_varmysys_var
 
std::vector< Ha_dataha_data
 
query_id_t query_id
 
query_id_t warn_query_id
 
global_read_lock_t _global_read_lock
 
killed_state_t volatile _killed
 
boost::shared_ptr
< catalog::Instance
_catalog
 
message::Transactiontransaction_message
 
message::Statementstatement_message
 
message::Resultsetresultset
 
plugin::EventObserverListsession_event_observers
 
uint64_t xa_id
 
const char * proc_info
 
bool abort_on_warning
 
bool concurrent_execute_allowed
 
bool tablespace_op
 
bool use_usage
 
rusage usage
 
identifier::user::mptr security_ctx
 
int32_t scoreboard_index
 
bool originating_server_uuid_set
 
std::string originating_server_uuid
 
uint64_t originating_commit_id
 
plugin::Clientclient
 

Detailed Description

Definition at line 81 of file session.h.

Member Typedef Documentation

typedef boost::shared_ptr<const std::string> drizzled::Session::QueryString

query associated with this statement

Definition at line 137 of file session.h.

Member Function Documentation

bool drizzled::Session::authenticate ( void  )

Authenticates users, with error reporting.

Returns true on success, or false on failure.

Definition at line 649 of file session.cc.

References drizzled::plugin::Client::authenticate().

bool drizzled::Session::checkUser ( const std::string &  passwd,
const std::string &  db 
)

Check if user exists and the password supplied is correct.

Returns true on success, and false on failure.

Note
Host, user and passwd may point to communication buffer. Current implementation does not depend on that, but future changes should be done with this in mind;
Parameters
passwdScrambled password received from client
dbDatabase name to connect to, may be NULL

Definition at line 659 of file session.cc.

References my_ok().

void drizzled::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 811 of file session.cc.

References _where, DEFAULT_WHERE, first_successful_insert_id_in_cur_stmt, first_successful_insert_id_in_prev_stmt, free_items(), and substitute_null_with_insert_id.

Referenced by drizzled::parse().

void drizzled::Session::close_data_files_and_morph_locks ( const identifier::Table identifier)

Close all instances of a table open by this thread and replace them with exclusive name-locks.

Parameters
sessionThread context
dbDatabase name for the table to be closed
table_nameName of the table to be closed
Note
This function assumes that if we are not under LOCK TABLES, then there is only one table open and locked. This means that the function probably has to be adjusted before it can be used anywhere outside ALTER Table.
Must not use TableShare::table_name/db of the table being closed, the strings are used in a loop even after the share may be freed.

Definition at line 1125 of file sql_base.cc.

Referenced by drizzled::internal_alter_table().

void drizzled::Session::close_old_data_files ( bool  morph_locks = false,
bool  send_refresh = false 
)

Close handlers for tables in list, but leave the Table structure intact so that we can re-open these quickly.

Parameters
sessionThread context
tableHead of the list of Table objects
morph_lockstrue - remove locks which we have on tables being closed but ensure that no DML or DDL will sneak in before we will re-open the table (i.e. temporarily morph our table-level locks into name-locks). false - otherwise
send_refreshShould we awake waiters even if we didn't close any tables?

Definition at line 1258 of file sql_base.cc.

References drizzled::locking::broadcast_refresh(), drizzled::Table::db_stat, and drizzled::Table::lock_count.

void drizzled::Session::close_tables_for_reopen ( TableList **  tables)

Prepares statement for reopening of tables and recalculation of set of prelocked tables.

Parameters
Pointerto a pointer to a list of tables which we were trying to open and lock

Definition at line 1753 of file session.cc.

References close_thread_tables(), and drizzled::TableList::next_global.

Referenced by openTablesLock().

void drizzled::Session::close_thread_tables ( )
void drizzled::Session::disconnect ( enum error_t  errcode = EE_OK)

Disconnects the session from a client connection and updates any status variables necessary.

Parameters
errcodeError code to print to console
Note
For the connection that is doing shutdown, this is called twice

Definition at line 1525 of file session.cc.

References drizzled::plugin::Client::close(), drizzled::plugin::Client::isConnected(), and variables.

void drizzled::Session::drop_open_table ( Table table,
const identifier::Table identifier 
)

Auxiliary routine which closes and drops open table.

Parameters
sessionThread handle
tableTable object for table to be dropped
db_nameName of database for this table
table_nameName of this table
Note
This routine assumes that table to be closed is open only by calling thread so we needn't wait until other threads will close the table. Also unless called under implicit or explicit LOCK TABLES mode it assumes that table to be dropped is already unlocked. In the former case it will also remove lock on the table. But one should not rely on this behaviour as it may change in future. Currently, however, this function is never called for a table that was locked with LOCK TABLES.

Definition at line 647 of file sql_base.cc.

void drizzled::Session::end_statement ( )

Cleanup statement parse state (parse tree, lex) and execution state after execution of a non-prepared SQL statement.

Todo:

Move this to Statement::~Statement

Definition at line 1462 of file session.cc.

References resetResultsetMessage().

Referenced by drizzled::parse().

bool drizzled::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.

Parameters
Completiontype

Definition at line 720 of file session.cc.

References drizzled::TransactionServices::commitTransaction(), and options.

bool drizzled::Session::executeStatement ( )

Executes a single statement received from the client connection.

Returns true if the statement was successful, or false otherwise.

Note

For profiling to work, it must never be called recursively.

In MySQL, this used to be the do_command() C function whic accepted a single parameter of the THD pointer.

Definition at line 677 of file session.cc.

References command, drizzled::dispatch_command(), drizzled::plugin::Client::readCommand(), and drizzled::Diagnostics_area::reset_diagnostics_area().

void drizzled::Session::free_items ( )

Frees all items attached to this Statement

Definition at line 351 of file session.cc.

References free_list.

Referenced by cleanup_after_query().

plugin::StorageEngine * drizzled::Session::getDefaultStorageEngine ( )

Return the default storage engine

Parameters
getDefaultStorageEngine()
Returns
pointer to plugin::StorageEngine

Definition at line 1889 of file session.cc.

References variables.

Referenced by drizzled::statement::CreateTable::execute().

table::Singular & drizzled::Session::getInstanceTable ( std::list< CreateField > &  field_list)

Create a reduced Table object with properly set up Field list from a list of field definitions.

The created table doesn't have a table Cursor associated with it, has no keys, no group/distinct, no copy_funcs array. The sole purpose of this Table object is to use the power of Field class to read/write data to/from table->getInsertRecord(). Then one can store the record in any container (RB tree, hash, etc). The table is created in Session mem_root, so are the table's fields. Consequently, if you don't BLOB fields, you don't need to free it.

Parameters
sessionconnection handle
field_listlist of column definitions
Returns
0 if out of memory, Table object in case of success

Definition at line 1838 of file session.cc.

message::Resultset* drizzled::Session::getResultsetMessage ( ) const
inline

Returns a pointer to the current Resulset message for this Session, or NULL if no active message.

Definition at line 905 of file session.h.

uint32_t drizzled::Session::getServerId ( ) const
inline

Accessor method returning the server's ID.

Definition at line 650 of file session.h.

Referenced by drizzled::TransactionServices::initTransactionMessage().

message::Transaction* drizzled::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 887 of file session.h.

Referenced by drizzled::TransactionServices::commitTransactionMessage(), drizzled::TransactionServices::getActiveTransactionMessage(), and drizzled::TransactionServices::setSavepoint().

query_id_t drizzled::Session::getWarningQueryId ( ) const
inline

Returns the Session's warning query ID

Definition at line 638 of file session.h.

bool drizzled::Session::inTransaction ( ) const
inline

Returns whether the session is currently inside a transaction

Definition at line 771 of file session.h.

Referenced by drizzled::statement::Truncate::execute(), and drizzled::execute_command().

bool drizzled::Session::is_error ( ) const

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 1871 of file session.cc.

Referenced by drizzled::plugin::QueryLog::afterStatement(), close_thread_tables(), drizzled::copy_funcs(), drizzled::delete_query(), drizzled::dispatch_command(), drizzled::do_select(), drizzled::evaluate_join_record(), drizzled::Join::exec(), drizzled::execute_command(), drizzled::handle_select(), drizzled::insert_query(), drizzled::internal_alter_table(), drizzled::Join::optimize(), drizzled::parse(), drizzled::parse_sql(), drizzled::Join::prepare(), drizzled::select_query(), drizzled::sql_set_variables(), and drizzled::update_query().

bool drizzled::Session::isViewable ( const identifier::User user_arg) const

Is this session viewable by the current user?

Definition at line 618 of file session.cc.

References drizzled::plugin::Authorization::isAuthorized().

Table * drizzled::Session::lock_table_name_if_not_cached ( const identifier::Table identifier)

Obtain an exclusive name lock on the table if it is not cached in the table cache.

Parameters
sessionThread context
dbName of database
table_nameName of table
[out]tableOut parameter which is either:
  • set to NULL if table cache contains record for the table or
  • set to point to the Table instance used for name-locking.
Note
This function takes into account all records for table in table cache, even placeholders used for name-locking. This means that 'table' parameter can be set to NULL for some situations when table does not really exist.
Return values
trueError occured (OOM)
falseSuccess. 'table' parameter set according to above rules.

Definition at line 760 of file sql_base.cc.

Referenced by drizzled::drizzle_create_table().

lex_string_t * drizzled::Session::make_lex_string ( lex_string_t lex_str,
str_ref  str 
)

Create a lex_string_t in this connection.

Parameters
lex_strpointer to lex_string_t object to be initialized
strinitializer to be copied into lex_str
lengthlength of str, in bytes
allocate_lex_stringif true, allocate new lex_string_t object, instead of using lex_str value
Returns
NULL on failure, or pointer to the lex_string_t object

Definition at line 847 of file session.cc.

References mem_root, and drizzled::memory::Root::strdup().

Referenced by drizzled::_schema_select(), and ha_innobase::get_foreign_key_list().

void drizzled::Session::markTransactionForRollback ( bool  all)

Mark transaction to rollback and mark error as fatal to a sub-statement.

Parameters
sessionThread handle
alltrue <=> rollback main transaction().

Definition at line 1519 of file session.cc.

References is_fatal_sub_stmt_error, and transaction_rollback_request.

Referenced by convert_error_code_to_mysql().

void drizzled::Session::my_eof ( )

A short cut for session->main_da().set_eof_status().

Definition at line 1884 of file session.cc.

References drizzled::Diagnostics_area::set_eof_status().

Referenced by drizzled::dispatch_command().

bool drizzled::Session::openTablesLock ( TableList tables)

Open all tables in list, locks them (all, including derived)

Parameters
Pointerto a list of tables for open & locking
Return values
false- ok
true- error
Note

The lock will automaticaly be freed by close_thread_tables()

Definition at line 1767 of file session.cc.

References close_tables_for_reopen().

Referenced by drizzled::delete_query(), drizzled::insert_query(), and drizzled::update_query().

void drizzled::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 538 of file session.cc.

References command, options, drizzled::memory::Root::reset_defaults(), set_proc_info(), and variables.

void drizzled::Session::readAndStoreQuery ( str_ref  v)

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.

Note
Used in COM_QUERY and COM_STMT_PREPARE.

Sets the following Session variables:

  • query
  • query_length
Parameters
Thepacket pointer to read from
Thelength of the query to read

Definition at line 706 of file session.cc.

References drizzled::plugin::QueryRewriter::rewriteQuery().

Referenced by drizzled::dispatch_command().

bool drizzled::Session::reopen_tables ( )

Reopen all tables with closed data files.

Parameters
sessionThread context
get_locksShould we get locks after reopening tables ?
mark_share_as_oldMark share as old to protect from a impending global read lock.
Note
Since this function can't properly handle prelocking and create placeholders it should be used in very special situations like FLUSH TABLES or ALTER Table. In general case one should just repeat open_tables()/lock_tables() combination when one needs tables to be reopened (for example see openTablesLock()).
One should have lock on table::Cache::mutex() when calling this.
Returns
false in case of success, true - otherwise.

Definition at line 1175 of file sql_base.cc.

References drizzled::locking::broadcast_refresh().

void drizzled::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.

Todo:

Make it a method of Session and align its name with the rest of reset/end/start/init methods.

Call it after we use Session for queries, not before.

Definition at line 1562 of file session.cc.

References examined_row_count, free_list, is_fatal_error, drizzled::Diagnostics_area::reset_diagnostics_area(), select_number, and sent_row_count.

Referenced by drizzled::parse().

void drizzled::Session::resetResultsetMessage ( )
inline

reset the active Resultset message used by the Query Cache plugin.

Definition at line 946 of file session.h.

Referenced by end_statement().

void drizzled::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 609 of file session.h.

Referenced by drizzled::delete_query(), drizzled::dispatch_command(), drizzled::Join::exec(), drizzled::execute_command(), drizzled::insert_query(), drizzled::internal_alter_table(), drizzled::Join::optimize(), drizzled::parse(), prepareForQueries(), drizzled::select_query(), and drizzled::update_query().

void drizzled::Session::set_schema ( const std::string &  new_db)

Set the current database; use deep copy of C-string.

Parameters
new_dba pointer to the new database name.
new_db_lenlength of the new database name.

Initialize the current database from a NULL-terminated string with length. If we run out of memory, we free the current database and return true. This way the user will notice the error as there will be no current database selected (in addition to the error message set by malloc).

Note
This operation just sets {db, db_length}. Switching the current database usually involves other actions, like switching other database attributes including security context. In the future, this operation will be made private and more convenient interface will be provided.

Definition at line 1507 of file session.cc.

void drizzled::Session::setQueryId ( query_id_t  in_query_id)
inline

Sets this Session's current query ID

Definition at line 619 of file session.h.

Referenced by drizzled::dispatch_command().

void drizzled::Session::setResultsetMessage ( message::Resultset in_message)
inline

Sets the active Resultset message used by the Query Cache plugin.

Parameters
[in]Pointerto the message

Definition at line 937 of file session.h.

void drizzled::Session::setTransactionMessage ( message::Transaction in_message)
inline

Sets the active transaction message used by the ReplicationServices component.

Parameters
[in]Pointerto the message

Definition at line 915 of file session.h.

Referenced by drizzled::TransactionServices::cleanupTransactionMessage(), and drizzled::TransactionServices::getActiveTransactionMessage().

void drizzled::Session::setWarningQueryId ( query_id_t  in_query_id)
inline

Sets this Session's warning query ID

Definition at line 632 of file session.h.

table::Placeholder & drizzled::Session::table_cache_insert_placeholder ( const identifier::Table arg)

Create and insert into table cache placeholder for table which will prevent its opening (or creation) (a.k.a lock table name).

Parameters
sessionThread context
keyTable cache key for name to be locked
key_lengthTable cache key length
Returns
Pointer to Table object used for name locking or 0 in case of failure.

Definition at line 722 of file sql_base.cc.

void drizzled::Session::unlink_open_table ( Table find)

Remove all instances of table from thread's open list and table cache.

Parameters
sessionThread context
findTable to remove
Note
because we risk the chance of deleting the share, we can't assume that it will exist past, this should be modified once we can use a TableShare::shared_ptr here.

Definition at line 591 of file sql_base.cc.

References drizzled::locking::broadcast_refresh().

Referenced by drizzled::drizzle_create_table(), and drizzled::internal_alter_table().

Member Data Documentation

const char* drizzled::Session::_where
private

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 270 of file session.h.

Referenced by cleanup_after_query().

enum_server_command drizzled::Session::command

Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from first byte of the packet in executeStatement()

Definition at line 322 of file session.h.

Referenced by drizzled::plugin::QueryLog::afterStatement(), drizzled::dispatch_command(), executeStatement(), and prepareForQueries().

ha_rows drizzled::Session::cuted_fields

Count of "cut" or truncated fields.

Todo:
Kill this friggin thing.

Definition at line 408 of file session.h.

Referenced by drizzled::insert_query(), drizzled::internal_alter_table(), drizzled::Field::set_warning(), drizzled::store_val_in_field(), and drizzled::update_query().

const char *const drizzled::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 174 of file session.h.

Referenced by cleanup_after_query().

bool drizzled::Session::derived_tables_processing

set during loop of derived table processing

Definition at line 567 of file session.h.

Referenced by drizzled::Join::prepare().

ha_rows drizzled::Session::examined_row_count

Number of rows we read, sent or not, including in create_sort_index()

Definition at line 419 of file session.h.

Referenced by drizzled::plugin::QueryLog::afterStatement(), drizzled::Join::exec(), and reset_for_next_command().

uint64_t drizzled::Session::first_successful_insert_id_in_cur_stmt

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 385 of file session.h.

Referenced by cleanup_after_query(), and drizzled::insert_query().

uint64_t drizzled::Session::first_successful_insert_id_in_prev_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 379 of file session.h.

Referenced by cleanup_after_query(), drizzled::insert_query(), drizzled::remove_eq_conds(), drizzled::update_query(), and drizzled::Item_func_last_insert_id::val_int().

Item* drizzled::Session::free_list

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 116 of file session.h.

Referenced by free_items(), drizzled::Item::Item(), and reset_for_next_command().

bool drizzled::Session::got_warning

Set on call to push_warning()

Definition at line 564 of file session.h.

Referenced by drizzled::Field_decimal::store().

bool drizzled::Session::is_fatal_error

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

See also
reset_session_for_next_command().

Definition at line 540 of file session.h.

Referenced by drizzled::add_ref_to_table_cond(), drizzled::change_refs_to_tmp_fields(), drizzled::create_tmp_table(), drizzled::delete_query(), drizzled::Join::exec(), drizzled::subselect_hash_sj_engine::exec(), drizzled::find_order_in_list(), drizzled::Join::optimize(), drizzled::parse_sql(), reset_for_next_command(), and drizzle_plugin::ClientMySQLProtocol::writeEOFPacket().

bool drizzled::Session::is_fatal_sub_stmt_error

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

See also
handler::ha_index_or_rnd_end() and only then perform the rollback). Reset to false when we leave the sub-statement mode.

Definition at line 558 of file session.h.

Referenced by markTransactionForRollback().

uint64_t drizzled::Session::limit_found_rows

We follow this logic:

  • when stmt starts, first_successful_insert_id_in_prev_stmt contains the first insert id successfully inserted by the previous stmt.
  • as stmt makes progress, handler::insert_id_for_cur_row changes; every time get_auto_increment() is called,
  • at first successful insertion of an autogenerated value, first_successful_insert_id_in_cur_stmt is set to handler::insert_id_for_cur_row.
  • when stmt ends, first_successful_insert_id_in_prev_stmt is set to first_successful_insert_id_in_cur_stmt.

Definition at line 399 of file session.h.

Referenced by drizzled::Join::exec(), and drizzled::handle_select().

THR_LOCK_OWNER* drizzled::Session::lock_id

If not main_lock_id, points to the lock_id of a cursor.

Definition at line 205 of file session.h.

THR_LOCK_INFO drizzled::Session::lock_info

Locking information for this session

Definition at line 203 of file session.h.

Lex_input_stream* drizzled::Session::m_lip

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 596 of file session.h.

Referenced by drizzled::check_simple_select(), and drizzled::parse_sql().

THR_LOCK_OWNER drizzled::Session::main_lock_id

To use for conventional queries

Definition at line 204 of file session.h.

bool drizzled::Session::no_warnings_for_error

no warnings on call to my_error()

Definition at line 565 of file session.h.

uint32_t drizzled::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 447 of file session.h.

Referenced by drizzled::Field_num::check_int(), drizzled::evaluate_join_record(), drizzled::insert_query(), drizzled::internal_alter_table(), drizzled::Field::set_warning(), drizzled::sub_select(), and drizzled::update_query().

int64_t drizzled::Session::row_count_func

For the ROW_COUNT() function

Definition at line 401 of file session.h.

Referenced by drizzled::delete_query(), drizzled::execute_command(), drizzled::insert_query(), and drizzled::update_query().

plugin::Scheduler* drizzled::Session::scheduler

Pointer to scheduler object

Definition at line 185 of file session.h.

uint32_t drizzled::Session::select_number

number of select (used for EXPLAIN)

Definition at line 498 of file session.h.

Referenced by reset_for_next_command().

ha_rows drizzled::Session::sent_row_count

Number of rows we actually sent to the client, including "synthetic" rows in ROLLUP etc.

Definition at line 414 of file session.h.

Referenced by drizzled::plugin::QueryLog::afterStatement(), drizzled::Join::exec(), and reset_for_next_command().

void* drizzled::Session::session_marker

Place to store various things

Definition at line 599 of file session.h.

Referenced by drizzled::handle_select().

bool drizzled::Session::substitute_null_with_insert_id

for IS NULL => = last_insert_id() fix in remove_eq_conds()

Definition at line 560 of file session.h.

Referenced by cleanup_after_query(), and drizzled::remove_eq_conds().

union { ... } drizzled::Session::sys_var_tmp

Used by the sys_var class to store temporary values

bool drizzled::Session::tablespace_op
private

This is true in DISCARD/IMPORT TABLESPACE

Definition at line 1103 of file session.h.

char* drizzled::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 211 of file session.h.

Referenced by drizzled::check_stack_overrun().

message::Transaction* drizzled::Session::transaction_message
private

Pointers to memory managed by the ReplicationServices component

Definition at line 1093 of file session.h.

bool drizzled::Session::transaction_rollback_request

Set by a storage engine to request the entire transaction (that possibly spans multiple engines) to rollback. Reset in ha_rollback.

Definition at line 546 of file session.h.

Referenced by drizzled::TransactionServices::autocommitOrRollback(), and markTransactionForRollback().

table_map drizzled::Session::used_tables

The set of those tables whose fields are referenced in all subqueries of the query.

Todo:

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 430 of file session.h.

Referenced by drizzled::insert_query(), drizzled::Join::optimize(), and drizzled::select_query().

UserVars drizzled::Session::user_vars
private

Hash of user variables defined during the session's lifetime

Definition at line 191 of file session.h.

uint32_t drizzled::Session::warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END]
Todo:

This, and some other variables like 'count_cuted_fields' maybe should be statement/cursor local, that is, moved to Statement class. With current implementation warnings produced in each prepared statement/cursor settle here.

Definition at line 440 of file session.h.

memory::Root drizzled::Session::warn_root

Allocation area for warnings and errors

Definition at line 176 of file session.h.


The documentation for this class was generated from the following files: