[continued from previous message]
return 0;
- }
-
- if (ids.size() == 1) {
- if (get(ids[0], out)) {
+ case 1: {
+ auto rc = get2(ids[0], out);
+ if (rc == 0) {
return ids[0];
}
+ if (rc == MDB_NOTFOUND) {
+ /* element not present, or has been marked deleted */
+ return 0;
+ }
+ throw std::runtime_error("in index get, failed (" + std::to_string(rc) + ")");
+ break;
+ }
+ default:
+ throw std::runtime_error("in index get, found more than one item");
}
-
- throw std::runtime_error("in index get, found more than one item");
}
// //! Cardinality of index N
diff -Nru pdns-4.9.4/modules/gmysqlbackend/smysql.cc pdns-4.9.7/modules/gmysqlbackend/smysql.cc
--- pdns-4.9.4/modules/gmysqlbackend/smysql.cc 2025-02-06 16:17:38.000000000 +0100
+++ pdns-4.9.7/modules/gmysqlbackend/smysql.cc 2025-07-07 09:42:15.000000000 +0200
@@ -116,7 +116,12 @@
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 @@
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;
diff -Nru pdns-4.9.4/modules/lmdbbackend/lmdbbackend.cc pdns-4.9.7/modules/lmdbbackend/lmdbbackend.cc
--- pdns-4.9.4/modules/lmdbbackend/lmdbbackend.cc 2025-02-06 16:17:38.000000000 +0100
+++ pdns-4.9.7/modules/lmdbbackend/lmdbbackend.cc 2025-07-07 09:42:15.000000000 +0200
@@ -656,8 +656,6 @@
string syncMode = toLower(getArg("sync-mode"));
- d_random_ids = mustDo("random-ids");
-
if (syncMode == "nosync")
d_asyncFlag = MDB_NOSYNC;
else if (syncMode == "nometasync")
@@ -667,17 +665,14 @@
else
throw std::runtime_error("Unknown sync mode " + syncMode + " requested for LMDB backend");
- uint64_t mapSize = 0;
+ d_mapsize = 0;
try {
- mapSize = std::stoll(getArg("map-size"));
+ d_mapsize = std::stoll(getArg("map-size"));
}
catch (const std::exception& e) {
throw std::runtime_error(std::string("Unable to parse the 'map-size' LMDB value: ") + e.what());
}
- LMDBLS::s_flag_deleted = mustDo("flag-deleted");
- d_handle_dups = false;
-
if (mustDo("lightning-stream")) {
d_random_ids = true;
d_handle_dups = true;
@@ -687,6 +682,11 @@
throw std::runtime_error(std::string("running with Lightning Stream support requires shards=1"));
}
}
+ else {
+ d_random_ids = mustDo("random-ids");
+ d_handle_dups = false;
+ LMDBLS::s_flag_deleted = mustDo("flag-deleted");
+ }
bool opened = false;
@@ -723,7 +723,7 @@
throw std::runtime_error("Somehow, we are not at schema version 5. Giving up");
}
- d_tdomains = std::make_shared<tdomains_t>(getMDBEnv(getArg("filename").c_str(), MDB_NOSUBDIR | d_asyncFlag, 0600, mapSize), "domains_v5");
+ d_tdomains = std::make_shared<tdomains_t>(getMDBEnv(getArg("filename").c_str(), MDB_NOSUBDIR | d_asyncFlag, 0600, d_mapsize), "domains_v5");
d_tmeta = std::make_shared<tmeta_t>(d_tdomains->getEnv(), "metadata_v5");
d_tkdb = std::make_shared<tkdb_t>(d_tdomains->getEnv(), "keydata_v5");
d_ttsig = std::make_shared<ttsig_t>(d_tdomains->getEnv(), "tsig_v5"); @@ -770,7 +770,7 @@
}
if (!opened) {
- d_tdomains = std::make_shared<tdomains_t>(getMDBEnv(getArg("filename").c_str(), MDB_NOSUBDIR | d_asyncFlag, 0600, mapSize), "domains_v5");
+ d_tdomains = std::make_shared<tdomains_t>(getMDBEnv(getArg("filename").c_str(), MDB_NOSUBDIR | d_asyncFlag, 0600, d_mapsize), "domains_v5");
d_tmeta = std::make_shared<tmeta_t>(d_tdomains->getEnv(), "metadata_v5");
d_tkdb = std::make_shared<tkdb_t>(d_tdomains->getEnv(), "keydata_v5");
d_ttsig = std::make_shared<ttsig_t>(d_tdomains->getEnv(), "tsig_v5");
@@ -1211,7 +1211,7 @@
auto& shard = d_trecords[id % s_shards];
if (!shard.env) {
shard.env = getMDBEnv((getArg("filename") + "-" + std::to_string(id % s_shards)).c_str(),
- MDB_NOSUBDIR | d_asyncFlag, 0600);
+ MDB_NOSUBDIR | d_asyncFlag, 0600, d_mapsize);
shard.dbi = shard.env->openDB("records_v5", MDB_CREATE);
}
auto ret = std::make_shared<RecordsRWTransaction>(shard.env->getRWTransaction());
@@ -1228,7 +1228,7 @@
throw DBException("attempting to start nested transaction without open parent env");
}
shard.env = getMDBEnv((getArg("filename") + "-" + std::to_string(id % s_shards)).c_str(),
- MDB_NOSUBDIR | d_asyncFlag, 0600);
+ MDB_NOSUBDIR | d_asyncFlag, 0600, d_mapsize);
shard.dbi = shard.env->openDB("records_v5", MDB_CREATE);
}
@@ -1405,10 +1405,7 @@
d_matchkey = co(di.id);
MDBOutVal key, val;
- auto a = d_getcursor->lower_bound(d_matchkey, key, val);
- auto b0 = key.getNoStripHeader<StringView>();
- auto b = b0.rfind(d_matchkey, 0);
- if (a || b != 0) {
+ if (d_getcursor->prefix(d_matchkey, key, val) != 0) {
d_getcursor.reset();
}
@@ -1470,7 +1467,7 @@
d_matchkey = co(zoneId, relqname, type.getCode());
}
- if (d_getcursor->lower_bound(d_matchkey, key, val) || key.getNoStripHeader<StringView>().rfind(d_matchkey, 0) != 0) {
+ if (d_getcursor->prefix(d_matchkey, key, val) != 0) {
d_getcursor.reset();
if (d_dolog) {
g_log << Logger::Warning << "Query " << ((long)(void*)this) << ": " << d_dtime.udiffNoReset() << " us to execute (found nothing)" << endl;
@@ -1508,7 +1505,7 @@
if (zr.dr.d_type == QType::NSEC3) {
// Hit a magic NSEC3 skipping
- if (d_getcursor->next(d_currentKey, d_currentVal) || d_currentKey.getNoStripHeader<StringView>().rfind(d_matchkey, 0) != 0) {
+ if (d_getcursor->next(d_currentKey, d_currentVal) != 0) {
// cerr<<"resetting d_getcursor 1"<<endl;
d_getcursor.reset();
}
@@ -1536,7 +1533,7 @@
if (d_currentrrsetpos >= d_currentrrset.size()) {
d_currentrrset.clear(); // will invalidate lrr
[continued in next message]
--- SoupGate-Win32 v1.05
* Origin: you cannot sedate... all the things you hate (1:229/2)