diff --git a/include/mysql/service_my_print_error.h b/include/mysql/service_my_print_error.h index 74ba6a2adb8..85a922215e4 100644 --- a/include/mysql/service_my_print_error.h +++ b/include/mysql/service_my_print_error.h @@ -31,6 +31,7 @@ extern "C" { #include #include #endif +#include #define ME_ERROR_LOG 64 /* Write the message to the error log */ #define ME_ERROR_LOG_ONLY 128 /* Write the error message to error log only */ @@ -40,8 +41,12 @@ extern "C" { extern struct my_print_error_service_st { void (*my_error_func)(unsigned int nr, unsigned long MyFlags, ...); - void (*my_printf_error_func)(unsigned int nr, const char *fmt, unsigned long MyFlags,...); - void (*my_printv_error_func)(unsigned int error, const char *format, unsigned long MyFlags, va_list ap); + void (*my_printf_error_func)(unsigned int nr, const char *fmt, + unsigned long MyFlags, ...) + ATTRIBUTE_FORMAT_FPTR(printf, 2, 4); + void (*my_printv_error_func)(unsigned int error, const char *format, + unsigned long MyFlags, va_list ap) + ATTRIBUTE_FORMAT_FPTR(printf, 2, 0); } *my_print_error_service; #ifdef MYSQL_DYNAMIC_PLUGIN @@ -52,8 +57,12 @@ extern struct my_print_error_service_st { #else extern void my_error(unsigned int nr, unsigned long MyFlags, ...); -extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...); -extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap); +extern void my_printf_error(unsigned int my_err, const char *format, + unsigned long MyFlags, ...) + ATTRIBUTE_FORMAT(printf, 2, 4); +extern void my_printv_error(unsigned int error, const char *format, + unsigned long MyFlags,va_list ap) + ATTRIBUTE_FORMAT(printf, 2, 0); #endif /* MYSQL_DYNAMIC_PLUGIN */ #ifdef __cplusplus diff --git a/include/service_versions.h b/include/service_versions.h index 0b48d59d29c..97d1fc62b9b 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -29,7 +29,7 @@ #define VERSION_logger 0x0100 #define VERSION_my_crypt 0x0100 #define VERSION_my_md5 0x0100 -#define VERSION_my_print_error 0x0100 +#define VERSION_my_print_error 0x0200 #define VERSION_my_sha1 0x0101 #define VERSION_my_sha2 0x0100 #define VERSION_my_snprintf 0x0200 diff --git a/plugin/auth_pam/auth_pam.c b/plugin/auth_pam/auth_pam.c index 86220f48183..753ec1bf8bc 100644 --- a/plugin/auth_pam/auth_pam.c +++ b/plugin/auth_pam/auth_pam.c @@ -62,7 +62,7 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) PAM_DEBUG((stderr, "PAM: opening pipes.\n")); if (pipe(p_to_c) < 0 || pipe(c_to_p) < 0) { - my_printf_error(ENOEXEC, "pam: cannot create pipes (errno: %M)", + my_printf_error(ENOEXEC, "pam: cannot create pipes (errno: %iE)", ME_ERROR_LOG_ONLY, errno); return CR_ERROR; } @@ -94,7 +94,7 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) if (res) { - my_printf_error(ENOEXEC, "pam: cannot exec %s (errno: %M)", + my_printf_error(ENOEXEC, "pam: cannot exec %s (errno: %iE)", ME_ERROR_LOG_ONLY, toolpath, errno); goto error_ret; } diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index f6ad4cc5811..5fc0e3373f3 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -755,7 +755,7 @@ static int user_coll_fill(struct user_coll *c, char *users, if (cmp_user && take_over_cmp) { ADD_ATOMIC(internal_stop_logging, 1); - CLIENT_ERROR(1, "User '%.*b' was removed from the" + CLIENT_ERROR(1, "User '%.*sB' was removed from the" " server_audit_excl_users.", MYF(ME_WARNING), (int) cmp_length, users); ADD_ATOMIC(internal_stop_logging, -1); @@ -765,7 +765,7 @@ static int user_coll_fill(struct user_coll *c, char *users, else if (cmp_user) { ADD_ATOMIC(internal_stop_logging, 1); - CLIENT_ERROR(1, "User '%.*b' is in the server_audit_incl_users, " + CLIENT_ERROR(1, "User '%.*sB' is in the server_audit_incl_users, " "so wasn't added.", MYF(ME_WARNING), (int) cmp_length, users); ADD_ATOMIC(internal_stop_logging, -1); remove_user(users); diff --git a/sql/field.cc b/sql/field.cc index 5815624c8de..2c29dc2e25a 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -988,14 +988,14 @@ bool Field::check_assignability_from(const Type_handler *from, */ if (table->s->db.str && table->s->table_name.str) my_printf_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, - "Cannot cast '%s' as '%s' in assignment of %`s.%`s.%`s", + "Cannot cast '%s' as '%s' in assignment of %sQ.%sQ.%sQ", MYF(error ? 0 : ME_WARNING), from->name().ptr(), type_handler()->name().ptr(), table->s->db.str, table->s->table_name.str, field_name.str); else my_printf_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, - "Cannot cast '%s' as '%s' in assignment of %`s", + "Cannot cast '%s' as '%s' in assignment of %sQ", MYF(error ? 0 : ME_WARNING), from->name().ptr(), type_handler()->name().ptr(), field_name.str); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 02c37b45d8f..74e88e8dd87 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -1033,7 +1033,7 @@ static Item *create_comparator(MY_XPATH *xpath, else my_printf_error(ER_UNKNOWN_ERROR, "XPATH error: " - "comparison of two nodesets is not supported: '%.32T'", + "comparison of two nodesets is not supported: '%.32sT'", MYF(0), context->beg); return 0; // TODO: Comparison of two nodesets @@ -2693,7 +2693,7 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath) my_printf_error(ER_UNKNOWN_ERROR, "Unknown XPATH variable at: '%.*s'", MYF(0), len, dollar_pos); else - my_printf_error(ER_UNKNOWN_ERROR, "Unknown XPATH variable at: '%.32T'", + my_printf_error(ER_UNKNOWN_ERROR, "Unknown XPATH variable at: '%.32sT'", MYF(0), dollar_pos); } } @@ -2829,7 +2829,7 @@ bool Item_xml_str_func::fix_fields(THD *thd, Item **ref) my_printf_error(ER_UNKNOWN_ERROR, "XPATH syntax error: '%.*s'", MYF(0), clen, xpath.lasttok.beg); else - my_printf_error(ER_UNKNOWN_ERROR, "XPATH syntax error: '%.32T'", + my_printf_error(ER_UNKNOWN_ERROR, "XPATH syntax error: '%.32sT'", MYF(0), xpath.lasttok.beg); return true; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 67fed298066..a59c81a5c45 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3497,12 +3497,12 @@ end: target user, so printing `priv_user@priv_host` is not incorrect. */ if (!host.str) - my_printf_error(ER_INVALID_ROLE, "User %`s@%`s has not been granted role %`s", + my_printf_error(ER_INVALID_ROLE, "User %sQ@%sQ has not been granted role %sQ", MYF(0), thd->security_ctx->priv_user, thd->security_ctx->priv_host, rolename.str); else /* Role is not granted but current user can see the role */ - my_printf_error(ER_INVALID_ROLE, "User %`s@%`s has not been granted role %`s", + my_printf_error(ER_INVALID_ROLE, "User %sQ@%sQ has not been granted role %sQ", MYF(0), user.str, host.str, rolename.str); } else diff --git a/sql/unireg.cc b/sql/unireg.cc index f70f62b18e6..fca005cc990 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -339,7 +339,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table, if (field_data_type_info_image.append(create_fields)) { my_printf_error(ER_CANT_CREATE_TABLE, - "Cannot create table %`s: " + "Cannot create table %sQ: " "Building the field data type info image failed.", MYF(0), table.str); DBUG_RETURN(frm); @@ -486,7 +486,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table, if (field_data_type_info_image.length() > 0xFFFF) { my_printf_error(ER_CANT_CREATE_TABLE, - "Cannot create table %`s: " + "Cannot create table %sQ: " "field data type info image is too large. " "Decrease the number of columns with " "extended data types.", @@ -553,7 +553,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table, if (key_info_length > UINT_MAX16) { my_printf_error(ER_CANT_CREATE_TABLE, - "Cannot create table %`s: index information is too long. " + "Cannot create table %sQ: index information is too long. " "Decrease number of indexes or use shorter index names or shorter comments.", MYF(0), table.str); goto err; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 3af84538da6..63fdc6231c0 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1036,7 +1036,7 @@ ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze() noexcept static void dict_table_open_failed(const table_name_t &name) { my_printf_error(ER_TABLE_CORRUPT, - "Table %`.*s.%`s is corrupted." + "Table %.*sQ.%sQ is corrupted." " Please drop the table and recreate.", MYF(ME_ERROR_LOG), int(name.dblen()), name.m_name, name.basename()); @@ -1077,7 +1077,7 @@ dict_table_open_on_name( ulint algo= table->space->get_compression_algo(); if (algo <= PAGE_ALGORITHM_LAST && !fil_comp_algo_loaded(algo)) my_printf_error(ER_PROVIDER_NOT_LOADED, - "Table %`.*s.%`s is compressed with %s," + "Table %.*sQ.%sQ is compressed with %s," " which is not currently loaded. " "Please load the %s provider plugin" " to open the table", diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c index e2f5fb4d8fb..4d360b98b4e 100644 --- a/storage/maria/ma_info.c +++ b/storage/maria/ma_info.c @@ -140,7 +140,7 @@ void _ma_report_error(int errcode, const LEX_STRING *name, myf flags) file_name+= length - 64; } } - my_printf_error(errcode, "Got error '%M' for '%s'", + my_printf_error(errcode, "Got error '%iE' for '%s'", flags, errcode, file_name); DBUG_VOID_RETURN; }