MySQL 源码解读 -- 基础结构之THD

THD 是最复杂的数据结构

1
2
3
4
class THD : public MDL_context_owner,
public Query_arena,
public Open_tables_state {
}

statement diagnoze area
thd->m_stmt_da

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
type = class Diagnostics_area {
private:
Diagnostics_area *m_stacked_da;
MEM_ROOT m_condition_root;
Sql_condition_list m_conditions_list;
List<Sql_condition const> m_preexisting_sql_conditions;
bool m_is_sent;
bool m_can_overwrite_status;
bool m_allow_unlimited_conditions;
Diagnostics_area::enum_diagnostics_status m_status;
char m_message_text[512];
char m_returned_sqlstate[6];
uint m_mysql_errno;
ulonglong m_affected_rows;
ulonglong m_last_insert_id;
uint m_last_statement_cond_count;
uint m_current_statement_cond_count;
uint m_current_statement_cond_count_by_sl[3];
ulong m_current_row_for_condition;
ulong m_saved_error_count;
ulong m_saved_warn_count;

typedef I_P_List<
Sql_condition,
I_P_List_adapter<Sql_condition, &Sql_condition::m_next_condition,
&Sql_condition::m_prev_condition>,
I_P_List_counter, I_P_List_fast_push_back<Sql_condition>>
Sql_condition_list;

thd->m_resource_group_ctx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

type = struct resourcegroups::Resource_group_ctx {
resourcegroups::Resource_group *m_cur_resource_group;
char m_switch_resource_group_str[65];
int m_warn;
}

type = class resourcegroups::Resource_group {
private:
std::string m_name;
resourcegroups::Type m_type;
bool m_enabled;
resourcegroups::Thread_resource_control m_thread_resource_control;
std::set<unsigned long long> m_pfs_thread_id_set;
std::mutex m_set_mutex;

public:
Resource_group(const std::string &, resourcegroups::Type, bool);
。。。
}