]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Handle LAST_INSERT_ID() returning zero as an error (no insertion)
authorMiod Vallat <miod.vallat@open-xchange.com>
Thu, 16 Jan 2025 13:56:48 +0000 (14:56 +0100)
committerMiod Vallat <miod.vallat@open-xchange.com>
Mon, 20 Jan 2025 17:28:17 +0000 (18:28 +0100)
modules/bindbackend/binddnssec.cc
pdns/backends/gsql/gsqlbackend.cc

index 191e22d10ab745167bcf61876e37628918c4408c..f378bf2ffbc696ac57b12f55c461bb41fe091571 100644 (file)
@@ -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) {
index 8ebb3c8acff797991236a304dff4dec666b8dec7..80668e61c54c1d67d42585d204a94b99ededdfc4 100644 (file)
@@ -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) {