MySQL Source code---Core class (1) Thread class

Source: Internet
Author: User
Tags thread class

Threading is a very important concept for MySQL. Threads are used to handle connections from clients, and threads and connections are 1:1 off. The thread and the THD object are also 1:1 corresponding relationships, some threads are set to take precedence, while some threads have no priority, and the thread's priority is set to Sql/mysql_priv.h

#define Interrupt_prior-2

#define Connect_prior-1

#define Wait_prior0

#define Query_prior2

(THD is the MySQL thread descriptor Class)


Thread initialization work:

void Thd::init (void)

{

Pthread_mutex_lock (&lock_global_system_variables);

Plugin_thdvar_init (this);

Variables.time_format= date_time_format_copy ((thd*) 0,

Variables.time_format);

Variables.date_format= date_time_format_copy ((thd*) 0,

Variables.date_format);

Variables.datetime_format= date_time_format_copy ((thd*) 0,

Variables.datetime_format);

/*

variables= global_system_variables above has reset

variables.pseudo_thread_id to 0. We need to correct it

Avoid temporary tables replication failure.

*/

Variables.pseudo_thread_id= thread_id;

Pthread_mutex_unlock (&lock_global_system_variables);

Server_status= Server_status_autocommit;

if (Variables.sql_mode & Mode_no_backslash_escapes)

Server_status|= server_status_no_backslash_escapes;

Options= thd_startup_options;


if (variables.max_join_size = = Ha_pos_error)

Options |= option_big_selects;

Else

Options &= ~option_big_selects;


transaction.all.modified_non_trans_table= transaction.stmt.modified_non_trans_table= FALSE;

Open_options=ha_open_options;

update_lock_default= (variables.low_priority_updates?

Tl_write_low_priority:

Tl_write);

session_tx_isolation= (enum_tx_isolation) variables.tx_isolation;

Update_charset ();

Reset_current_stmt_binlog_row_based ();

Bzero (char *) &status_var, sizeof (Status_var));

sql_log_bin_toplevel= Options & Option_bin_log;


#if defined (enabled_debug_sync)

/* Initialize the Debug Sync Facility. See debug_sync.cc. */

Debug_sync_init_thread (this);

#endif/* Defined (enabled_debug_sync) */

}


There are some cleanup and other functions that walk in the file to implement




This article is from the Linux OPS blog, so be sure to keep this source http://2853725.blog.51cto.com/2843725/1544160

MySQL Source---core class (1) thread class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.