diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-04 19:48:20 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-04 19:48:20 +0100 |
commit | 3526af7ec50e46aaa73d038566f42554f70f27b0 (patch) | |
tree | 2591708ced4743213f77c9aa4ee8933dc0d1b333 /libpqpp/pq-connection.cpp | |
parent | Pedantic only with gcc (diff) | |
download | libdbpp-postgresql-1.4.10.tar.bz2 libdbpp-postgresql-1.4.10.tar.xz libdbpp-postgresql-1.4.10.zip |
Fix a lot of clang-tidy warningsHEADlibdbpp-postgresql-1.4.10main
Diffstat (limited to 'libpqpp/pq-connection.cpp')
-rw-r--r-- | libpqpp/pq-connection.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/libpqpp/pq-connection.cpp b/libpqpp/pq-connection.cpp index 5c50b7c..13bc42e 100644 --- a/libpqpp/pq-connection.cpp +++ b/libpqpp/pq-connection.cpp @@ -41,8 +41,8 @@ PQ::ConnectionError::ConnectionError(const PGconn * conn) : PQ::Error(conn) { } PQ::Connection::Connection(const std::string & info) : conn(PQconnectdb(info.c_str())) { if (PQstatus(conn) != CONNECTION_OK) { - auto dc = std::unique_ptr<PGconn, decltype(&PQfinish)>(conn, &PQfinish); - throw ConnectionError(dc.get()); + auto connDeleter = std::unique_ptr<PGconn, decltype(&PQfinish)>(conn, &PQfinish); + throw ConnectionError(conn); } PQsetNoticeProcessor(conn, noNoticeProcessor, nullptr); } @@ -91,10 +91,8 @@ PQ::Connection::bulkUpdateStyle() const void PQ::Connection::ping() const { - struct pollfd fd { - // NOLINTNEXTLINE(hicpp-signed-bitwise) - PQsocket(conn), POLLRDHUP | POLLERR | POLLHUP | POLLNVAL, 0 - }; + struct pollfd fd {// NOLINTNEXTLINE(hicpp-signed-bitwise) + PQsocket(conn), POLLRDHUP | POLLERR | POLLHUP | POLLNVAL, 0}; if (PQstatus(conn) != CONNECTION_OK || poll(&fd, 1, 0)) { if (inTx()) { @@ -149,11 +147,11 @@ PQ::Connection::beginBulkUpload(const char * table, const char * extra) void PQ::Connection::endBulkUpload(const char * msg) { - int rc; - while (!(rc = PQputCopyEnd(conn, msg))) { + int result = 0; + while (!(result = PQputCopyEnd(conn, msg))) { sleep(1); } - if (rc != 1) { + if (result != 1) { throw Error(conn); } checkResult(PQgetResult(conn), PGRES_COMMAND_OK); @@ -162,29 +160,31 @@ PQ::Connection::endBulkUpload(const char * msg) size_t PQ::Connection::bulkUploadData(const char * data, size_t len) const { - int rc; - while (!(rc = PQputCopyData(conn, data, static_cast<int>(len)))) { + int result = 0; + while (!(result = PQputCopyData(conn, data, static_cast<int>(len)))) { sleep(1); } - if (rc != 1) { + if (result != 1) { throw Error(conn); } return len; } -static const std::string selectLastVal("SELECT lastval()"); -static const DB::CommandOptionsCPtr selectLastValOpts - = std::make_shared<DB::CommandOptions>(std::hash<std::string>()(selectLastVal)); +namespace { + const std::string SELECT_LAST_VAL("SELECT lastval()"); + const DB::CommandOptionsCPtr SELECT_LAST_VAL_OPTS + = std::make_shared<DB::CommandOptions>(std::hash<std::string>()(SELECT_LAST_VAL)); +} int64_t PQ::Connection::insertId() { - BulkSelectCommand getId(this, selectLastVal, nullptr, selectLastValOpts); - int64_t id = -1; + BulkSelectCommand getId(this, SELECT_LAST_VAL, nullptr, SELECT_LAST_VAL_OPTS); + int64_t insertId = -1; while (getId.fetch()) { - getId[0] >> id; + getId[0] >> insertId; } - return id; + return insertId; } int |