From f908818556315908b01866797b76a4802d76549f Mon Sep 17 00:00:00 2001 From: Dave Gosselin Date: Fri, 5 Jun 2026 13:03:11 -0400 Subject: [PATCH] MDEV-39870: macOSB Build Warning on Typecast On THD::reset, typecast the result of query_start_sec_part() to tv_usec in a more portable way. Previously, we assumed that the left hand side was always long-compatible but that isn't the case on mac. --- sql/sql_class.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 011995f99431b..5791a565b096d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3289,7 +3289,16 @@ class THD: public THD_count, /* this must be first */ void reset(THD *thd) { tv_sec= thd->query_start(); - tv_usec= (long) thd->query_start_sec_part(); + + /* + The type of tv_usec depends on the system and on macOS + it is __darwin_suseconds_t. Using decltype is system + agnostic because its result is whatever the underlying + type of tv_usec is. This should be more portable than + assuming that the left hand side is (long) (the previous + cast value). + */ + tv_usec= static_cast(thd->query_start_sec_part()); } } start_time;