268
int thd_in_lock_tables(const THD *thd)
268
int session_in_lock_tables(const Session *session)
270
return test(thd->in_lock_tables);
270
return test(session->in_lock_tables);
275
int thd_tablespace_op(const THD *thd)
275
int session_tablespace_op(const Session *session)
277
return test(thd->tablespace_op);
277
return test(session->tablespace_op);
282
Set the process info field of the THD structure.
282
Set the process info field of the Session structure.
284
284
This function is used by plug-ins. Internally, the
285
THD::set_proc_info() function should be used.
285
Session::set_proc_info() function should be used.
287
@see THD::set_proc_info
287
@see Session::set_proc_info
290
set_thd_proc_info(THD *thd, const char *info)
292
thd->set_proc_info(info);
296
const char *get_thd_proc_info(THD *thd)
298
return thd->get_proc_info();
302
void **thd_ha_data(const THD *thd, const struct handlerton *hton)
304
return (void **) &thd->ha_data[hton->slot].ha_ptr;
308
int64_t thd_test_options(const THD *thd, int64_t test_options)
310
return thd->options & test_options;
314
int thd_sql_command(const THD *thd)
316
return (int) thd->lex->sql_command;
320
int thd_tx_isolation(const THD *thd)
322
return (int) thd->variables.tx_isolation;
326
void thd_inc_row_count(THD *thd)
290
set_session_proc_info(Session *session, const char *info)
292
session->set_proc_info(info);
296
const char *get_session_proc_info(Session *session)
298
return session->get_proc_info();
302
void **session_ha_data(const Session *session, const struct handlerton *hton)
304
return (void **) &session->ha_data[hton->slot].ha_ptr;
308
int64_t session_test_options(const Session *session, int64_t test_options)
310
return session->options & test_options;
314
int session_sql_command(const Session *session)
316
return (int) session->lex->sql_command;
320
int session_tx_isolation(const Session *session)
322
return (int) session->variables.tx_isolation;
326
void session_inc_row_count(Session *session)
328
session->row_count++;
570
void THD::push_internal_handler(Internal_error_handler *handler)
570
void Session::push_internal_handler(Internal_error_handler *handler)
573
573
TODO: The current implementation is limited to 1 handler at a time only.
574
THD and sp_rcontext need to be modified to use a common handler stack.
574
Session and sp_rcontext need to be modified to use a common handler stack.
576
576
assert(m_internal_handler == NULL);
577
577
m_internal_handler= handler;
581
bool THD::handle_error(uint32_t sql_errno, const char *message,
581
bool Session::handle_error(uint32_t sql_errno, const char *message,
582
582
DRIZZLE_ERROR::enum_warning_level level)
584
584
if (m_internal_handler)
593
void THD::pop_internal_handler()
593
void Session::pop_internal_handler()
595
595
assert(m_internal_handler != NULL);
596
596
m_internal_handler= NULL;
600
void *thd_alloc(THD *thd, unsigned int size)
602
return thd->alloc(size);
606
void *thd_calloc(THD *thd, unsigned int size)
608
return thd->calloc(size);
612
char *thd_strdup(THD *thd, const char *str)
614
return thd->strdup(str);
618
char *thd_strmake(THD *thd, const char *str, unsigned int size)
620
return thd->strmake(str, size);
624
LEX_STRING *thd_make_lex_string(THD *thd, LEX_STRING *lex_str,
600
void *session_alloc(Session *session, unsigned int size)
602
return session->alloc(size);
606
void *session_calloc(Session *session, unsigned int size)
608
return session->calloc(size);
612
char *session_strdup(Session *session, const char *str)
614
return session->strdup(str);
618
char *session_strmake(Session *session, const char *str, unsigned int size)
620
return session->strmake(str, size);
624
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
625
625
const char *str, unsigned int size,
626
626
int allocate_lex_string)
628
return thd->make_lex_string(lex_str, str, size,
628
return session->make_lex_string(lex_str, str, size,
629
629
(bool) allocate_lex_string);
633
void *thd_memdup(THD *thd, const void* str, unsigned int size)
633
void *session_memdup(Session *session, const void* str, unsigned int size)
635
return thd->memdup(str, size);
635
return session->memdup(str, size);
639
void thd_get_xid(const THD *thd, DRIZZLE_XID *xid)
639
void session_get_xid(const Session *session, DRIZZLE_XID *xid)
641
*xid = *(DRIZZLE_XID *) &thd->transaction.xid_state.xid;
641
*xid = *(DRIZZLE_XID *) &session->transaction.xid_state.xid;
645
645
Init common variables that has to be reset on start and on change_user
648
void Session::init(void)
650
650
pthread_mutex_lock(&LOCK_global_system_variables);
651
plugin_thdvar_init(this);
652
variables.time_format= date_time_format_copy((THD*) 0,
651
plugin_sessionvar_init(this);
652
variables.time_format= date_time_format_copy((Session*) 0,
653
653
variables.time_format);
654
variables.date_format= date_time_format_copy((THD*) 0,
654
variables.date_format= date_time_format_copy((Session*) 0,
655
655
variables.date_format);
656
variables.datetime_format= date_time_format_copy((THD*) 0,
656
variables.datetime_format= date_time_format_copy((Session*) 0,
657
657
variables.datetime_format);
659
659
variables= global_system_variables above has reset
897
897
assert(thread_stack);
899
if (pthread_setspecific(THR_THD, this) ||
899
if (pthread_setspecific(THR_Session, this) ||
900
900
pthread_setspecific(THR_MALLOC, &mem_root))
902
902
mysys_var=my_thread_var;
904
904
Let mysqld define the thread id (not mysys)
905
This allows us to move THD to different threads if needed.
905
This allows us to move Session to different threads if needed.
907
907
mysys_var->id= thread_id;
908
908
real_id= pthread_self(); // For debugging
911
We have to call thr_lock_info_init() again here as THD may have been
911
We have to call thr_lock_info_init() again here as Session may have been
912
912
created in another thread
914
914
thr_lock_info_init(&lock_info);
1212
1212
Register an item tree tree transformation, performed by the query
1213
1213
optimizer. We need a pointer to runtime_memroot because it may be !=
1214
thd->mem_root (this may no longer be a true statement)
1214
session->mem_root (this may no longer be a true statement)
1217
void THD::nocheck_register_item_tree_change(Item **place, Item *old_value,
1217
void Session::nocheck_register_item_tree_change(Item **place, Item *old_value,
1218
1218
MEM_ROOT *runtime_memroot)
1220
1220
Item_change_record *change;
1334
1334
We may be passing the control from mysqld to the client: release the
1335
1335
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
1338
ha_release_temporary_latches(thd);
1338
ha_release_temporary_latches(session);
1340
1340
List_iterator_fast<Item> li(items);
1341
Protocol *protocol= thd->protocol;
1341
Protocol *protocol= session->protocol;
1342
1342
char buff[MAX_FIELD_WIDTH];
1343
1343
String buffer(buff, sizeof(buff), &my_charset_bin);
1370
1370
We may be passing the control from mysqld to the client: release the
1371
1371
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
1374
ha_release_temporary_latches(thd);
1374
ha_release_temporary_latches(session);
1376
1376
/* Unlock tables before sending packet to gain some speed */
1379
mysql_unlock_tables(thd, thd->lock);
1379
mysql_unlock_tables(session, session->lock);
1383
1383
is_result_set_started= 0;
1484
1484
if (!dirname_length(exchange->file_name))
1486
strxnmov(path, FN_REFLEN-1, mysql_real_data_home, thd->db ? thd->db : "",
1486
strxnmov(path, FN_REFLEN-1, mysql_real_data_home, session->db ? session->db : "",
1488
1488
(void) fn_format(path, exchange->file_name, path, "", option);
2090
2090
if (mv->local == 0)
2092
2092
Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item);
2093
suv->fix_fields(thd, 0);
2093
suv->fix_fields(session, 0);
2098
return(thd->is_error());
2098
return(session->is_error());
2101
2101
bool select_dumpvar::send_eof()
2103
2103
if (! row_count)
2104
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2104
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2105
2105
ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA));
2107
2107
In order to remember the value of affected rows for ROW_COUNT()
2108
2108
function, SELECT INTO has to have an own SQLCOM.
2109
2109
TODO: split from SQLCOM_SELECT
2111
::my_ok(thd,row_count);
2111
::my_ok(session,row_count);
2131
void thd_increment_bytes_sent(ulong length)
2131
void session_increment_bytes_sent(ulong length)
2133
THD *thd=current_thd;
2134
if (likely(thd != 0))
2135
{ /* current_thd==0 when close_connection() calls net_send_error() */
2136
thd->status_var.bytes_sent+= length;
2133
Session *session=current_session;
2134
if (likely(session != 0))
2135
{ /* current_session==0 when close_connection() calls net_send_error() */
2136
session->status_var.bytes_sent+= length;
2141
void thd_increment_bytes_received(ulong length)
2143
current_thd->status_var.bytes_received+= length;
2147
void thd_increment_net_big_packet_count(ulong length)
2149
current_thd->status_var.net_big_packet_count+= length;
2152
void THD::send_kill_message() const
2141
void session_increment_bytes_received(ulong length)
2143
current_session->status_var.bytes_received+= length;
2147
void session_increment_net_big_packet_count(ulong length)
2149
current_session->status_var.net_big_packet_count+= length;
2152
void Session::send_kill_message() const
2154
2154
int err= killed_errno();
2156
2156
my_message(err, ER(err), MYF(0));
2159
void THD::set_status_var_init()
2159
void Session::set_status_var_init()
2161
2161
memset(&status_var, 0, sizeof(status_var));
2224
2224
Check the killed state of a user thread
2225
@param thd user thread
2225
@param session user thread
2226
2226
@retval 0 the user thread is active
2227
2227
@retval 1 the user thread has been killed
2229
extern "C" int thd_killed(const THD *thd)
2229
extern "C" int session_killed(const Session *session)
2231
return(thd->killed);
2231
return(session->killed);
2235
2235
Return the thread id of a user thread
2236
@param thd user thread
2236
@param session user thread
2237
2237
@return thread id
2239
extern "C" unsigned long thd_get_thread_id(const THD *thd)
2239
extern "C" unsigned long session_get_thread_id(const Session *session)
2241
return((unsigned long)thd->thread_id);
2241
return((unsigned long)session->thread_id);
2245
2245
#ifdef INNODB_COMPATIBILITY_HOOKS
2246
extern "C" const struct charset_info_st *thd_charset(THD *thd)
2248
return(thd->charset());
2251
extern "C" char **thd_query(THD *thd)
2253
return(&thd->query);
2256
extern "C" int thd_slave_thread(const THD *thd)
2258
return(thd->slave_thread);
2261
extern "C" int thd_non_transactional_update(const THD *thd)
2263
return(thd->transaction.all.modified_non_trans_table);
2266
extern "C" int thd_binlog_format(const THD *thd)
2268
return (int) thd->variables.binlog_format;
2271
extern "C" void thd_mark_transaction_to_rollback(THD *thd, bool all)
2273
mark_transaction_to_rollback(thd, all);
2246
extern "C" const struct charset_info_st *session_charset(Session *session)
2248
return(session->charset());
2251
extern "C" char **session_query(Session *session)
2253
return(&session->query);
2256
extern "C" int session_slave_thread(const Session *session)
2258
return(session->slave_thread);
2261
extern "C" int session_non_transactional_update(const Session *session)
2263
return(session->transaction.all.modified_non_trans_table);
2266
extern "C" int session_binlog_format(const Session *session)
2268
return (int) session->variables.binlog_format;
2271
extern "C" void session_mark_transaction_to_rollback(Session *session, bool all)
2273
mark_transaction_to_rollback(session, all);
2275
2275
#endif // INNODB_COMPATIBILITY_HOOKS */
2279
2279
Mark transaction to rollback and mark error as fatal to a sub-statement.
2281
@param thd Thread handle
2281
@param session Thread handle
2282
2282
@param all true <=> rollback main transaction.
2285
void mark_transaction_to_rollback(THD *thd, bool all)
2285
void mark_transaction_to_rollback(Session *session, bool all)
2289
thd->is_fatal_sub_stmt_error= true;
2290
thd->transaction_rollback_request= all;
2289
session->is_fatal_sub_stmt_error= true;
2290
session->transaction_rollback_request= all;
2293
2293
/***************************************************************************
2482
2482
compiling option.
2484
2484
template Rows_log_event*
2485
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2485
Session::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2486
2486
Write_rows_log_event*);
2488
2488
template Rows_log_event*
2489
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2489
Session::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2490
2490
Delete_rows_log_event *);
2492
2492
template Rows_log_event*
2493
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2493
Session::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2494
2494
Update_rows_log_event *);
2752
2752
Error code, or 0 if no error.
2754
int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
2754
int Session::binlog_query(Session::enum_binlog_query_type qtype, char const *query_arg,
2755
2755
ulong query_len, bool is_trans, bool suppress_use,
2756
THD::killed_state killed_status_arg)
2756
Session::killed_state killed_status_arg)
2758
2758
assert(query_arg && mysql_bin_log.is_open());