]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
mysql: use MYSQL_TYPE_LONGLONG on 64bit platforms 15345/head
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 21 Mar 2025 11:54:21 +0000 (12:54 +0100)
committerMiod Vallat <miod.vallat@powerdns.com>
Mon, 24 Mar 2025 06:23:04 +0000 (07:23 +0100)
Found on s390x

(cherry picked from commit 3f4aaf81caf5f4549e7bfcf3a3c746168c9c4175)

modules/gmysqlbackend/smysql.cc

index efcbffd18e451a34fa035be683f1c5c0d38cd110..d289798c9b6f96dfa5e2efe0ed13ea0f476e3eef 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;