From afd243cc87827c94f0cea73748ffc5c1fdf1880a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 12 Jun 2021 20:54:28 +0100 Subject: Avoid direct use of runtime_error in PostgreSQL stuff Adds proper exception which extends it and gets the PostgreSQL error message. --- lib/output/pq/pqStmt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/output/pq/pqStmt.cpp') diff --git a/lib/output/pq/pqStmt.cpp b/lib/output/pq/pqStmt.cpp index 078c239..dc258b6 100644 --- a/lib/output/pq/pqStmt.cpp +++ b/lib/output/pq/pqStmt.cpp @@ -24,8 +24,8 @@ namespace MyGrate::Output::Pq { Bindings b {vs}; res = {PQexecPrepared(conn, name.c_str(), (int)vs.size(), b.values.data(), b.lengths.data(), nullptr, 0), &PQclear}; - verify( - PQresultStatus(res.get()) == PGRES_COMMAND_OK || PQresultStatus(res.get()) == PGRES_TUPLES_OK, name); + verify(PQresultStatus(res.get()) == PGRES_COMMAND_OK || PQresultStatus(res.get()) == PGRES_TUPLES_OK, + name, conn); } std::size_t @@ -48,7 +48,7 @@ namespace MyGrate::Output::Pq { } auto nam {scprintf<"pst%0x">(c->stmts.size())}; ResPtr res {PQprepare(c->conn.get(), nam.c_str(), q, (int)n, nullptr), PQclear}; - verify(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q); + verify(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q, c->conn.get()); return c->stmts.emplace(q, std::move(nam)).first->second; } } -- cgit v1.2.3