From: Chris Hofstaedtler Date: Fri, 21 Mar 2025 11:54:21 +0000 (+0100) Subject: mysql: use MYSQL_TYPE_LONGLONG on 64bit platforms X-Git-Tag: dnsdist-2.0.0-alpha2~126^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f4aaf81caf5f4549e7bfcf3a3c746168c9c4175;p=thirdparty%2Fpdns.git mysql: use MYSQL_TYPE_LONGLONG on 64bit platforms Found on s390x --- 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;