]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
mysql: use MYSQL_TYPE_LONGLONG on 64bit platforms 15340/head
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 21 Mar 2025 11:54:21 +0000 (12:54 +0100)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 21 Mar 2025 12:55:09 +0000 (13:55 +0100)
Found on s390x

modules/gmysqlbackend/smysql.cc

index d9f484bbd3e853385eca89d1d0d068303fbe6c7e..ae5add9a4ed5410fdf437ace3389611fedc0eeb7 100644 (file)
@@ -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;