From 92214117fd3de5fd50f7256d75179b5cd49a5039 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Sun, 1 Sep 2024 15:27:32 -0600 Subject: [PATCH] Extract some of #3360 fixes to 10.6.x That PR uncovered countless issues on `my_snprintf` uses. This commit backports a squashed subset of their fixes (excludes #3485). --- sql/ha_partition.cc | 4 ++-- sql/log.cc | 2 +- sql/partition_info.cc | 2 +- sql/semisync_master.cc | 2 +- storage/innobase/btr/btr0btr.cc | 2 +- storage/innobase/dict/dict0load.cc | 6 +++--- storage/innobase/handler/ha_innodb.cc | 2 +- storage/innobase/os/os0file.cc | 4 ++-- storage/innobase/row/row0sel.cc | 2 +- storage/maria/ma_info.c | 2 +- storage/maria/ma_loghandler.c | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 52e6dc4bf9f8f..32a59eca2cf58 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1474,8 +1474,8 @@ bool print_admin_msg(THD* thd, uint len, Also we likely need to lock mutex here (in both cases with protocol and push_warning). */ - DBUG_PRINT("info",("print_admin_msg: %s, %s, %s, %s", name, op_name, - msg_type, msgbuf)); + DBUG_PRINT("info",("print_admin_msg: %s, %s, %s, %s", name, op_name->str, + msg_type->str, msgbuf)); protocol->prepare_for_resend(); protocol->store(name, length, system_charset_info); protocol->store(op_name, system_charset_info); diff --git a/sql/log.cc b/sql/log.cc index 512be2e2a6de5..be5836cac2c78 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -11412,7 +11412,7 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, Query_log_event *query_ev= (Query_log_event*) ev; if (query_ev->xid) { - DBUG_PRINT("QQ", ("xid: %llu xid")); + DBUG_PRINT("QQ", ("xid: %llu xid", query_ev->xid)); DBUG_ASSERT(sizeof(query_ev->xid) == sizeof(my_xid)); uchar *x= (uchar *) memdup_root(&mem_root, (uchar*) &query_ev->xid, diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 3cefeae32b69c..14afc1c74a789 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -178,7 +178,7 @@ bool partition_info::add_named_partition(const char *part_name, size_t length) } DBUG_PRINT("info", ("Found partition %u is_subpart %d for name %.*s", part_def->part_id, part_def->is_subpart, - length, part_name)); + (int) length, part_name)); DBUG_RETURN(false); } diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc index e7d7fa80251c9..bea125ca50c92 100644 --- a/sql/semisync_master.cc +++ b/sql/semisync_master.cc @@ -1445,7 +1445,7 @@ void Repl_semi_sync_master::await_all_slave_replies(const char *msg) if (msg && first) { first= false; - sql_print_information(msg); + sql_print_information("%s", msg); } wait_result= diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index e386c162ed9e3..224397cab9008 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -194,7 +194,7 @@ static bool btr_root_fseg_validate(ulint offset, sql_print_error("InnoDB: Index root page " UINT32PF " in %s is corrupted " "at " ULINTPF, block.page.id().page_no(), - UT_LIST_GET_FIRST(space.chain)->name); + UT_LIST_GET_FIRST(space.chain)->name, offset); return false; } diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index d79d3eab8c3cd..5f2e8a5449029 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -2300,9 +2300,9 @@ dict_load_tablespace( table->file_unreadable = true; if (!(ignore_err & DICT_ERR_IGNORE_RECOVER_LOCK)) { - sql_print_error("InnoDB: Failed to load tablespace " - ULINTPF " for table %s", - table->space_id, table->name); + sql_print_error("InnoDB: Failed to load tablespace %" + PRIu32 " for table %s", + table->space_id, table->name.m_name); } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 9869d0d0356fa..d2760bceb8119 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2036,7 +2036,7 @@ static int innodb_check_version(handlerton *hton, const char *path, const trx_id_t trx_id= table->def_trx_id; DBUG_ASSERT(trx_id <= create_id); dict_table_close(table); - DBUG_PRINT("info", ("create_id: %llu trx_id: %llu", create_id, trx_id)); + DBUG_PRINT("info", ("create_id: %llu trx_id: %" PRIu64, create_id, trx_id)); DBUG_RETURN(create_id != trx_id); } else diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 45cb24c251c76..9c8dcca4aafbe 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -2776,7 +2776,7 @@ os_file_io( if (type.type != IORequest::READ_MAYBE_PARTIAL) { sql_print_warning("InnoDB: %zu bytes should have been" - " %s at %llu from %s," + " %s at %" PRIu64 " from %s," " but got only %zd." " Retrying.", n, type.is_read() @@ -2950,7 +2950,7 @@ os_file_read_func( os_file_handle_error_cond_exit(type.node ? type.node->name : nullptr, "read", false, false); - sql_print_error("InnoDB: Tried to read %zu bytes at offset %llu" + sql_print_error("InnoDB: Tried to read %zu bytes at offset %" PRIu64 " of file %s, but was only able to read %zd", n, offset, type.node ? type.node->name : "(unknown)", n_bytes); diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 199fdcc0fe729..cab4f073aeb6f 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -6776,7 +6776,7 @@ dberr_t row_check_index(row_prebuilt_t *prebuilt, ulint *n_rows) { push_warning_printf(prebuilt->trx->mysql_thd, Sql_condition::WARN_LEVEL_WARN, ER_NOT_KEYFILE, - "InnoDB: Invalid PAGE_MAX_TRX_ID=%llu" + "InnoDB: Invalid PAGE_MAX_TRX_ID=%" PRIu64 " in index '%-.200s'", page_trx_id, index->name()); prebuilt->autoinc_error= DB_INDEX_CORRUPT; diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c index ddf92654be025..1a1018ce52cbf 100644 --- a/storage/maria/ma_info.c +++ b/storage/maria/ma_info.c @@ -149,7 +149,7 @@ void _ma_report_error(int errcode, const LEX_STRING *name, myf flags) } } my_printf_error(errcode, "Got error '%M' for '%s'", - flags, (int) errcode, file_name); + flags, errcode, file_name); DBUG_VOID_RETURN; } diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index ffbcfecae95e9..e2c3ef3fb2190 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -8705,7 +8705,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low) log_descriptor.open_files.elements); DBUG_ASSERT(log_descriptor.min_file == i); file= *((TRANSLOG_FILE **)pop_dynamic(&log_descriptor.open_files)); - DBUG_PRINT("info", ("Files : %d", log_descriptor.open_files.elements)); + DBUG_PRINT("info", ("Files : %zu", log_descriptor.open_files.elements)); DBUG_ASSERT(i == file->number); log_descriptor.min_file++; DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==