• Bug#1108915: unblock: pdns/4.9.7-1 [pre-approval] (2/5)

    From Chris =?utf-8?Q?Hofst=C3=A4dtler?=@1:229/2 to All on Mon Jul 7 18:10:01 2025
    [continued from previous message]

    --- pdns-4.9.4/debian/patches/upstream/0001-mysql-use-MYSQL_TYPE_LONGLONG-on-64bit-platforms.patch 2025-03-21 13:09:34.000000000 +0100
    +++ pdns-4.9.7/debian/patches/upstream/0001-mysql-use-MYSQL_TYPE_LONGLONG-on-64bit-platforms.patch 1970-01-01 01:00:00.000000000 +0100
    @@ -1,43 +0,0 @@
    -From: Chris Hofstaedtler <[email protected]>
    -Date: Fri, 21 Mar 2025 12:54:21 +0100
    -Subject: mysql: use MYSQL_TYPE_LONGLONG on 64bit platforms
    -
    -Found on s390x.
    -
    -https://github.com/PowerDNS/pdns/pull/15340/
    ----
    - 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 efcbffd..4cc7856 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].buf
  • From Sebastian Ramacher@1:229/2 to All on Tue Jul 8 08:10:01 2025
    [continued from previous message]

    -upstream/0001-mysql-use-MYSQL_TYPE_LONGLONG-on-64bit-platforms.patch
    diff -Nru pdns-4.9.4/debian/patches/upstream/0001-mysql-use-MYSQL_TYPE_LONGLONG-on-64bit-platforms.patch pdns-4.9.7/debian/patches/upstream/0001-mysql-use-MYSQL_TYPE_LONGLONG-on-64bit-platforms.patch
    --- pdns-4.9.4/debian/patches/upstream/0001-mysql-use-MYSQL_TYPE_LONGLONG-on-64bit-platforms.patch 2025-03-21 13:09:34.000000000 +0100
    +++ pdns-4.9.7/debian/patches/upstream/0001-mysql-use-MYSQL_TYPE_LONGLONG-on-64bit-platforms.patch 1970-01-01 01:00:00.000000000 +0100
    @@ -1,43 +0,0 @@
    -From: Chris Hofstaedtler <[email protected]>
    -Date: Fri, 21 Mar 2025 12:54:21 +0100
    -Subject: mysql: use MYSQL_TYPE_LONGLONG on 64bit platforms
    -
    -Found on s390x.
    -
    -https://github.com/PowerDNS/pdns/pull/15340/
    ----
    - 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 efcbffd..4cc7856 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;
    -+ }
    -+ else {
    -+ d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONGLONG;
    -+ }
    - 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;
    -+ }
    -+ else {
    -+ d_req_bind[d_paridx].buffer_type = MYSQL_TYPE_LONGLONG;
    -+ }
    - 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;
    diff -Nru pdns-4.9.4/docs/ixfrdist.yml.5 pdns-4.9.7/docs/ixfrdist.yml.5
    --- pdns-4.9.4/docs/ixfrdist.yml.5 2025-02-06 16:19:08.000000000 +0100
    +++ pdns-4.9.7/docs/ixfrdist.yml.5 2025-07-07 09:43:48.000000000 +0200
    @@ -27,7 +27,7 @@
    .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
    .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
    ..
    -.TH "IXFRDIST.YML" "5" "Feb 06, 2025" "" "PowerDNS Authoritative Server" +.TH "IXFRDIST.YML" "5" "Jul 07, 2025" "" "PowerDNS Authoritative Server"
    .SH NAME
    ixfrdist.yml \- The ixfrdist configuration file
    .SH SYNOPSIS
    diff -Nru pdns-4.9.4/ext/lmdb-safe/lmdb-safe.hh pdns-4.9.7/ext/lmdb-safe/lmdb-safe.hh
    --- pdns-4.9.4/ext/lmdb-safe/lmdb-safe.hh 2025-02-06 16:17:38.000000000 +0100
    +++ pdns-4.9.7/ext/lmdb-safe/lmdb-safe.hh 2025-07-07 09:42:15.000000000 +0200
    @@ -12,6 +12,8 @@
    #include <mutex>
    #include <vector>
    #include <algorithm>
    +#include <string>
    +#include <string_view>

    #include "config.h"

    @@ -24,6 +26,13 @@
    #endif

    using std::string_view;
    +using std::string;
    +
    +#if BOOST_VERSION >= 106100
    +#define StringView string_view
    +#else
    +#define StringView string
    +#endif

    /* open issues:
    *
    @@ -98,7 +107,7 @@
    std::map<std::thread::id, int> d_ROtransactionsOut;
    };

    -std::shared_ptr<MDBEnv> getMDBEnv(const char* fname, int flags, int mode, uint64_t mapsizeMB=(sizeof(void *)==4) ? 100 : 16000);
    +std::shared_ptr<MDBEnv> getMDBEnv(const char* fname, int flags, int mode, uint64_t mapsizeMB);

    #ifndef DNSDIST

    @@ -300,6 +309,9 @@
    return ret;
    }

    + template <class T>
    + T get() const;
    +
    operator MDB_val&()
    {
    return d_mdbval;
    @@ -312,6 +324,12 @@
    #endif
    };

    +template <>
    +inline std::string MDBInVal::get<std::string>() const
    +{
    + return {static_cast<char*>(d_mdbval.mv_data), d_mdbval.mv_size};
    +}
    +
    class MDBROCursor;

    class MDBROTransactionImpl
    @@ -415,6 +433,7 @@
    private:
    std::vector<T*> *d_registry;
    MDB_cursor* d_cursor{nullptr};
    + std::string d_prefix{""};
    public:
    MDB_txn* d_txn{nullptr}; // ew, public
    uint64_t d_txtime{0};
    @@ -523,6 +542,9 @@

    while (true) {
    auto sval = data.getNoStripHeader<std::string_view>();
    + if (d_prefix.length() > 0 && key.getNoStripHeader<StringView>().rfind(d_prefix, 0) != 0) {
    + return MDB_NOTFOUND;
    + }

    if (!LMDBLS::LSisDeleted(sval)) {
    // done!
    @@ -573,6 +595,7 @@
    public:
    int get(MDBOutVal& key, MDBOutVal& data, MDB_cursor_op op)
    {
    + d_prefix.clear();
    int rc = mdb_cursor_get(d_cursor, &key.d_mdbval, &data.d_mdbval, op);
    if(rc && rc != MDB_NOTFOUND)
    throw std::runtime_error("Unable to get from cursor: " + std::string(mdb_strerror(rc)));
    @@ -581,6 +604,7 @@

    int find(const MDBInVal& in, MDBOutVal& key, MDBOutVal& data)
    {
    + d_prefix.clear();
    key.d_mdbval = in.d_mdbval;
    int rc=mdb_cursor_get(d_cursor, const_cast<MDB_val*>(&key.d_mdbval), &data.d_mdbval, MDB_SET);
    if(rc && rc != MDB_NOTFOUND)
    @@ -588,8 +612,20 @@
    return skipDeleted(key, data, MDB_SET, rc);
    }

    + int prefix(const MDBInVal& in, MDBOutVal& key, MDBOutVal& data)
    + {
    + d_prefix = in.get<string>();
    + return _lower_bound(in, key, data);
    + }
    +
    int lower_bound(const MDBInVal& in, MDBOutVal& key, MDBOutVal& data)
    {
    + d_prefix.clear();
    + return _lower_bound(in, key, data);
    + }
    +
    + int _lower_bound(const MDBInVal& in, MDBOutVal& key, MDBOutVal& data) // used by prefix() and lower_bound()
    + {
    key.d_mdbval = in.d_mdbval;

    int rc = mdb_cursor_get(d_cursor, const_cast<MDB_val*>(&key.d_mdbval), &data.d_mdbval, MDB_SET_RANGE);
    diff -Nru pdns-4.9.4/ext/lmdb-safe/lmdb-typed.hh pdns-4.9.7/ext/lmdb-safe/lmdb-typed.hh
    --- pdns-4.9.4/ext/lmdb-safe/lmdb-typed.hh 2025-02-06 16:17:38.000000000 +0100
    +++ pdns-4.9.7/ext/lmdb-safe/lmdb-typed.hh 2025-07-07 09:42:15.000000000 +0200
    @@ -284,14 +284,19 @@
    // }

    //! Get item with id, from main table directly
    - bool get(uint32_t id, T& t)
    + int get2(uint32_t itemId, T& value)
    {
    - MDBOutVal data;
    - if((*d_parent.d_txn)->get(d_parent.d_parent->d_main, id, data))
    - return false;
    -
    - serFromString(data.get<std::string>(), t);
    - return true;
    + MDBOutVal data{};
    + int rc;
    + rc = (*d_parent.d_txn)->get(d_parent.d_parent->d_main, itemId, data); + if (rc == 0) {
    + serFromString(data.get<std::string>(), value);
    + }
    + return rc;
    + }
    + bool get(uint32_t itemId, T& value)
    + {
    + return get2(itemId, value) == 0;
    }

    //! Get item through index N, then via the main database
    @@ -309,17 +314,24 @@
    // because we know we only want one item, pass onlyOldest=true to consistently get the same one out of a set of duplicates
    get_multi<N>(key, ids, true);

    - if (ids.size() == 0) {
    + switch (ids.size()) {
    + case 0:

    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)