From 3f4aaf81caf5f4549e7bfcf3a3c746168c9c4175 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Fri, 21 Mar 2025 12:54:21 +0100 Subject: [PATCH] mysql: use MYSQL_TYPE_LONGLONG on 64bit platforms Found on s390x --- modules/gmysqlbackend/smysql.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/gmysqlbackend/smysql.cc b/modules/gmysqlbackend/smysql.cc index d9f484bbd3..ae5add9a4e 100644 --- a/modules/gmysqlbackend/smysql.cc +++ b/modules/gmysqlbackend/smysql.cc @@ -116,7 +116,12 @@ public: releaseStatement(); throw SSqlException("Attempt to bind more parameters than query has: " + d_query); } - d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONG; + if constexpr (sizeof(long) == 4) { + d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONG; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + } + else { + d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONGLONG; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + } d_req_bind[d_paridx].buffer = new long[1]; *((long*)d_req_bind[d_paridx].buffer) = value; d_paridx++; @@ -129,7 +134,12 @@ public: releaseStatement(); throw SSqlException("Attempt to bind more parameters than query has: " + d_query); } - d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONG; + if constexpr (sizeof(long) == 4) { + d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONG; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + } + else { + d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONGLONG; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + } d_req_bind[d_paridx].buffer = new unsigned long[1]; d_req_bind[d_paridx].is_unsigned = 1; *((unsigned long*)d_req_bind[d_paridx].buffer) = value; -- 2.47.2