From 7919673a4ba54fc6696a7c4d42128188bdbad369 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Fri, 7 Jun 2019 14:08:26 +0200 Subject: [PATCH] report sqlite3 extended error codes --- pdns/ssqlite3.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pdns/ssqlite3.cc b/pdns/ssqlite3.cc index eb7075388..752c72950 100644 --- a/pdns/ssqlite3.cc +++ b/pdns/ssqlite3.cc @@ -46,6 +46,11 @@ int pdns_sqlite3_clear_bindings(sqlite3_stmt *pStmt){ return rc; } +static string SSQLite3ErrorString(sqlite3 *db) +{ + return string(sqlite3_errmsg(db)+string(" (")+std::to_string(sqlite3_extended_errcode(db))+string(")")); +} + class SSQLite3Statement: public SSqlStatement { public: @@ -86,8 +91,8 @@ public: // failed. releaseStatement(); if (d_rc == SQLITE_CANTOPEN) - throw SSqlException(string("CANTOPEN error in sqlite3, often caused by unwritable sqlite3 db *directory*: ")+string(sqlite3_errmsg(d_db->db()))); - throw SSqlException(string("Error while retrieving SQLite query results: ")+string(sqlite3_errmsg(d_db->db()))); + throw SSqlException(string("CANTOPEN error in sqlite3, often caused by unwritable sqlite3 db *directory*: ")+SSQLite3ErrorString(d_db->db())); + throw SSqlException(string("Error while retrieving SQLite query results: ")+SSQLite3ErrorString(d_db->db())); } if(d_dolog) g_log<db())); + throw SSqlException(string("Unable to compile SQLite statement : '")+d_query+"': "+SSQLite3ErrorString(d_db->db())); } if (pTail && strlen(pTail)>0) g_log<