From aebd16201f85e356a08179eca048db66d027b560 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 21 May 2024 21:04:41 +0200 Subject: [PATCH] don't use session locale for the error log --- sql/log.cc | 2 +- sql/opt_histogram_json.cc | 2 +- sql/partition_info.cc | 2 +- sql/rpl_mi.cc | 6 ++---- sql/sql_acl.cc | 4 ++-- sql/sql_class.cc | 2 +- sql/sql_class.h | 2 +- sql/sql_db.cc | 4 ++-- sql/sql_plugin.cc | 2 +- sql/sql_udf.cc | 6 +++--- sql/thr_malloc.cc | 2 +- 11 files changed, 16 insertions(+), 18 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index c9812e39757..0d2adffc3a0 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3418,7 +3418,7 @@ err: if (!write_error) { write_error= 1; - sql_print_error(ER_THD(thd, ER_ERROR_ON_WRITE), name, errno); + sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, errno); } goto end; } diff --git a/sql/opt_histogram_json.cc b/sql/opt_histogram_json.cc index a28dee10fef..020e07527d4 100644 --- a/sql/opt_histogram_json.cc +++ b/sql/opt_histogram_json.cc @@ -829,7 +829,7 @@ err: ER_THD(thd, ER_JSON_HISTOGRAM_PARSE_FAILED), db_name, table_name, err, (je.s.c_str - (const uchar*)hist_data)); - sql_print_error(ER_THD(thd, ER_JSON_HISTOGRAM_PARSE_FAILED), + sql_print_error(ER_DEFAULT(ER_JSON_HISTOGRAM_PARSE_FAILED), db_name, table_name, err, (je.s.c_str - (const uchar*)hist_data)); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 422ca66d5a7..6390dfab3b4 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1038,7 +1038,7 @@ void partition_info::vers_check_limit(THD *thd) table->s->db.str, table->s->table_name.str, vers_info->hist_part->partition_name.str, "LIMIT"); - sql_print_warning(ER_THD(thd, WARN_VERS_PART_FULL), + sql_print_warning(ER_DEFAULT(WARN_VERS_PART_FULL), table->s->db.str, table->s->table_name.str, vers_info->hist_part->partition_name.str, "LIMIT"); } diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 45303365b1f..4f28f1f8edf 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -1188,8 +1188,7 @@ bool Master_info_index::init_all_master_info() else { /* Master_info already in HASH */ - sql_print_error(ER_THD_OR_DEFAULT(current_thd, - ER_CONNECTION_ALREADY_EXISTS), + sql_print_error(ER_DEFAULT(ER_CONNECTION_ALREADY_EXISTS), (int) connection_name.length, connection_name.str, (int) connection_name.length, connection_name.str); mi->unlock_slave_threads(); @@ -1207,8 +1206,7 @@ bool Master_info_index::init_all_master_info() Sql_condition::WARN_LEVEL_NOTE)) { /* Master_info was already registered */ - sql_print_error(ER_THD_OR_DEFAULT(current_thd, - ER_CONNECTION_ALREADY_EXISTS), + sql_print_error(ER_DEFAULT(ER_CONNECTION_ALREADY_EXISTS), (int) connection_name.length, connection_name.str, (int) connection_name.length, connection_name.str); mi->unlock_slave_threads(); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index a4d02ad037d..ecd10f3a4fb 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -13326,7 +13326,7 @@ static void login_failed_error(THD *thd) */ if (global_system_variables.log_warnings > 1) { - sql_print_warning(ER_THD(thd, access_denied_error_code(thd->password)), + sql_print_warning(ER_DEFAULT(access_denied_error_code(thd->password)), thd->main_security_ctx.user, thd->main_security_ctx.host_or_ip, thd->password ? ER_THD(thd, ER_YES) : ER_THD(thd, ER_NO)); @@ -14966,7 +14966,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) if (global_system_variables.log_warnings > 1) { Security_context* sctx = thd->security_ctx; - sql_print_warning(ER_THD(thd, err), + sql_print_warning(ER_DEFAULT(err), sctx->priv_user, sctx->priv_host, mpvio.db.str); } } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 76701972e7e..9441e8066c5 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -7651,7 +7651,7 @@ static void print_unsafe_warning_to_log(THD *thd, int unsafe_type, char* buf, DBUG_ENTER("print_unsafe_warning_in_log"); sprintf(buf, ER_THD(thd, ER_BINLOG_UNSAFE_STATEMENT), ER_THD(thd, LEX::binlog_stmt_unsafe_errcode[unsafe_type])); - sql_print_warning(ER_THD(thd, ER_MESSAGE_AND_STATEMENT), buf, query); + sql_print_warning(ER_DEFAULT(ER_MESSAGE_AND_STATEMENT), buf, query); DBUG_VOID_RETURN; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 68c94acb497..d8d9a847fa7 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5440,7 +5440,7 @@ public: } } Security_context *sctx= &main_security_ctx; - sql_print_warning(ER_THD(this, ER_NEW_ABORTING_CONNECTION), + sql_print_warning(ER_DEFAULT(ER_NEW_ABORTING_CONNECTION), thread_id, (db.str ? db.str : "unconnected"), sctx->user ? sctx->user : "unauthenticated", sctx->host_or_ip, real_ip_str, reason); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 0eeec41342e..f9750ca6d8c 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -589,7 +589,7 @@ bool load_db_opt(THD *thd, const char *path, Schema_specification_st *create) get_charset_by_name(pos+1, MYF(utf8_flag)))) { sql_print_error("Error while loading database options: '%s':",path); - sql_print_error(ER_THD(thd, ER_UNKNOWN_CHARACTER_SET),pos+1); + sql_print_error(ER_DEFAULT(ER_UNKNOWN_CHARACTER_SET),pos+1); create->default_table_charset= default_charset_info; } } @@ -598,7 +598,7 @@ bool load_db_opt(THD *thd, const char *path, Schema_specification_st *create) if (!(create->default_table_charset= get_charset_by_name(pos+1, MYF(utf8_flag)))) { sql_print_error("Error while loading database options: '%s':",path); - sql_print_error(ER_THD(thd, ER_UNKNOWN_COLLATION),pos+1); + sql_print_error(ER_DEFAULT(ER_UNKNOWN_COLLATION),pos+1); create->default_table_charset= default_charset_info; } } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 76846a69d05..dd6a4d251d2 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1962,7 +1962,7 @@ static void plugin_load(MEM_ROOT *tmp_root) mysql_mutex_unlock(&LOCK_plugin); } if (unlikely(error > 0)) - sql_print_error(ER_THD(new_thd, ER_GET_ERRNO), my_errno, + sql_print_error(ER_DEFAULT(ER_GET_ERRNO), my_errno, table->file->table_type()); end_read_record(&read_record_info); table->mark_table_for_reopen(); diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 692feb93cbe..1eb1b8c550b 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -98,7 +98,7 @@ static const char *init_syms(udf_func *tmp, char *nm) if (!opt_allow_suspicious_udfs) return nm; if (thd->variables.log_warnings) - sql_print_warning(ER_THD(thd, ER_CANT_FIND_DL_ENTRY), nm, tmp->name.str); + sql_print_warning(ER_DEFAULT(ER_CANT_FIND_DL_ENTRY), nm, tmp->name.str); } return 0; } @@ -252,7 +252,7 @@ void udf_init() if (!(dl= dlopen(dlpath, RTLD_NOW))) { /* Print warning to log */ - sql_print_error(ER_THD(new_thd, ER_CANT_OPEN_LIBRARY), + sql_print_error(ER_DEFAULT(ER_CANT_OPEN_LIBRARY), tmp->dl, errno, my_dlerror(dlpath)); /* Keep the udf in the hash so that we can remove it later */ continue; @@ -265,7 +265,7 @@ void udf_init() const char *missing; if ((missing= init_syms(tmp, buf))) { - sql_print_error(ER_THD(new_thd, ER_CANT_FIND_DL_ENTRY), missing, + sql_print_error(ER_DEFAULT(ER_CANT_FIND_DL_ENTRY), missing, tmp->name.str); del_udf(tmp); if (new_dl) diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index 89ad359befa..8f5cd6921d4 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -54,7 +54,7 @@ extern "C" { /* Skip writing to the error log to avoid mtr complaints */ DBUG_EXECUTE_IF("simulate_out_of_memory", return;); - sql_print_error("%s", ER_THD_OR_DEFAULT(thd, ER_OUT_OF_RESOURCES)); + sql_print_error(ER_DEFAULT(ER_OUT_OF_RESOURCES)); } }