Skip to content

Commit

Permalink
Set thd->query() for internal (startup) transactions
Browse files Browse the repository at this point in the history
This helps with debugging as 'Query: ' in DBUG traces will show something
useful, for internal transactions, instead of just "".
  • Loading branch information
montywi authored and spetrunia committed Feb 3, 2023
1 parent 0ba4712 commit 6418c24
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sql/ddl_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2741,6 +2741,8 @@ int ddl_log_execute_recovery()
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->init(); // Needed for error messages
thd->set_query_inner((char*) STRING_WITH_LEN("intern:ddl_log_execute_recovery"),
default_charset_info);

thd->log_all_errors= (global_system_variables.log_warnings >= 3);
recovery_state.drop_table.free();
Expand Down
2 changes: 2 additions & 0 deletions sql/events.cc
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ Events::init(THD *thd, bool opt_noacl_or_bootstrap)
*/
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->set_query_inner((char*) STRING_WITH_LEN("intern:Events::init"),
default_charset_info);
/*
Set current time for the thread that handles events.
Current time is stored in data member start_time of THD class.
Expand Down
5 changes: 5 additions & 0 deletions sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,8 @@ bool acl_init(bool dont_read_acl_tables)
DBUG_RETURN(1); /* purecov: inspected */
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->set_query_inner((char*) STRING_WITH_LEN("intern:acl_init"),
default_charset_info);
/*
It is safe to call acl_reload() since acl_* arrays and hashes which
will be freed there are global static objects and thus are initialized
Expand Down Expand Up @@ -8001,6 +8003,9 @@ bool grant_init()
DBUG_RETURN(1); /* purecov: deadcode */
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->set_query_inner((char*) STRING_WITH_LEN("intern:grant_init"),
default_charset_info);

return_val= grant_reload(thd);
delete thd;
DBUG_RETURN(return_val);
Expand Down
3 changes: 3 additions & 0 deletions sql/sql_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,7 @@ static bool register_builtin(struct st_maria_plugin *plugin,
/*
called only by plugin_init()
*/

static void plugin_load(MEM_ROOT *tmp_root)
{
TABLE_LIST tables;
Expand All @@ -1847,6 +1848,8 @@ static void plugin_load(MEM_ROOT *tmp_root)

new_thd->thread_stack= (char*) &tables;
new_thd->store_globals();
new_thd->set_query_inner((char*) STRING_WITH_LEN("intern:plugin_load"),
default_charset_info);
new_thd->db= MYSQL_SCHEMA_NAME;
bzero((char*) &new_thd->net, sizeof(new_thd->net));
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_READ);
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_reload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
{
thd->thread_stack= (char*) &tmp_thd;
thd->store_globals();
thd->set_query_inner((char*) STRING_WITH_LEN("intern:reload_acl"),
default_charset_info);
}

if (likely(thd))
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_servers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ bool servers_init(bool dont_read_servers_table)
DBUG_RETURN(TRUE);
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->set_query_inner((char*) STRING_WITH_LEN("intern:servers_init"),
default_charset_info);
/*
It is safe to call servers_reload() since servers_* arrays and hashes which
will be freed there are global static objects and thus are initialized
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_udf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ void udf_init()
initialized = 1;
new_thd->thread_stack= (char*) &new_thd;
new_thd->store_globals();
new_thd->set_query_inner((char*) STRING_WITH_LEN("intern:udf_init"),
default_charset_info);
new_thd->set_db(&MYSQL_SCHEMA_NAME);

tables.init_one_table(&new_thd->db, &MYSQL_FUNC_NAME, 0, TL_READ);
Expand Down
2 changes: 2 additions & 0 deletions sql/tztime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,8 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
DBUG_RETURN(1);
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->set_query_inner((char*) STRING_WITH_LEN("intern:my_tz_init"),
default_charset_info);

/* Init all memory structures that require explicit destruction */
if (my_hash_init(key_memory_tz_storage, &tz_names, &my_charset_latin1, 20, 0,
Expand Down

0 comments on commit 6418c24

Please sign in to comment.