From: Miod Vallat Date: Thu, 16 Jan 2025 13:56:48 +0000 (+0100) Subject: Handle LAST_INSERT_ID() returning zero as an error (no insertion) X-Git-Tag: dnsdist-2.0.0-alpha1~143^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af08518c7c4179ac35aaf5e982eb1be054c18964;p=thirdparty%2Fpdns.git Handle LAST_INSERT_ID() returning zero as an error (no insertion) --- diff --git a/modules/bindbackend/binddnssec.cc b/modules/bindbackend/binddnssec.cc index 191e22d10a..f378bf2ffb 100644 --- a/modules/bindbackend/binddnssec.cc +++ b/modules/bindbackend/binddnssec.cc @@ -375,6 +375,10 @@ bool Bind2Backend::addDomainKey(const DNSName& name, const KeyData& key, int64_t ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1); id = std::stoi(row[0]); d_GetLastInsertedKeyIdQuery_stmt->reset(); + if (id == 0) { + // No insert took place, report as error. + id = -1; + } return true; } catch (SSqlException& e) { diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 8ebb3c8acf..80668e61c5 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -1030,6 +1030,10 @@ bool GSQLBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1); id = std::stoi(row[0]); d_GetLastInsertedKeyIdQuery_stmt->reset(); + if (id == 0) { + // No insert took place, report as error. + id = -1; + } return true; } catch (SSqlException &e) {