summaryrefslogtreecommitdiff
path: root/lib/output/pq
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/pq')
-rw-r--r--lib/output/pq/pqConn.cpp7
-rw-r--r--lib/output/pq/pqRecordSet.cpp8
-rw-r--r--lib/output/pq/pqStmt.cpp6
-rw-r--r--lib/output/pq/writePqCopyStrm.cpp2
4 files changed, 12 insertions, 11 deletions
diff --git a/lib/output/pq/pqConn.cpp b/lib/output/pq/pqConn.cpp
index 983271e..6d89fb7 100644
--- a/lib/output/pq/pqConn.cpp
+++ b/lib/output/pq/pqConn.cpp
@@ -34,7 +34,8 @@ namespace MyGrate::Output::Pq {
PqConn::query(const char * const q, const std::initializer_list<DbValue> & vs)
{
Bindings b {vs};
- ResPtr res {PQexecParams(conn.get(), q, (int)vs.size(), nullptr, b.values.data(), b.lengths.data(), nullptr, 0),
+ ResPtr res {PQexecParams(conn.get(), q, static_cast<int>(vs.size()), nullptr, b.values.data(), b.lengths.data(),
+ nullptr, 0),
&PQclear};
verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q, res.get());
}
@@ -72,8 +73,8 @@ namespace MyGrate::Output::Pq {
{nullptr,
[](void * cookie, const char * buf, size_t size) {
auto conn = static_cast<PqConn *>(cookie)->conn.get();
- verify<PqErr>(PQputCopyData(conn, buf, (int)size) == 1, "copy data", conn);
- return (ssize_t)size;
+ verify<PqErr>(PQputCopyData(conn, buf, static_cast<int>(size)) == 1, "copy data", conn);
+ return static_cast<ssize_t>(size);
},
nullptr,
[](void * cookie) {
diff --git a/lib/output/pq/pqRecordSet.cpp b/lib/output/pq/pqRecordSet.cpp
index 4d5349f..9eeb3cd 100644
--- a/lib/output/pq/pqRecordSet.cpp
+++ b/lib/output/pq/pqRecordSet.cpp
@@ -30,12 +30,12 @@ namespace MyGrate::Output::Pq {
DbValue
PqRecordSet::at(std::size_t row, std::size_t col) const
{
- if (PQgetisnull(res.get(), (int)row, (int)col)) {
+ if (PQgetisnull(res.get(), static_cast<int>(row), static_cast<int>(col))) {
return nullptr;
}
- const auto value {PQgetvalue(res.get(), (int)row, (int)col)};
- const auto size {static_cast<size_t>(PQgetlength(res.get(), (int)row, (int)col))};
- const auto type {PQftype(res.get(), (int)col)};
+ const auto value {PQgetvalue(res.get(), static_cast<int>(row), static_cast<int>(col))};
+ const auto size {static_cast<size_t>(PQgetlength(res.get(), static_cast<int>(row), static_cast<int>(col)))};
+ const auto type {PQftype(res.get(), static_cast<int>(col))};
switch (type) {
// case BITOID: TODO bool
// case BOOLOID: TODO bool
diff --git a/lib/output/pq/pqStmt.cpp b/lib/output/pq/pqStmt.cpp
index c6399e4..bb7a79c 100644
--- a/lib/output/pq/pqStmt.cpp
+++ b/lib/output/pq/pqStmt.cpp
@@ -22,8 +22,8 @@ namespace MyGrate::Output::Pq {
PqPrepStmt::execute(const std::span<const DbValue> vs)
{
Bindings b {vs};
- res = {PQexecPrepared(
- conn, name.c_str(), (int)vs.size(), b.values.data(), b.lengths.data(), b.formats.data(), 0),
+ res = {PQexecPrepared(conn, name.c_str(), static_cast<int>(vs.size()), b.values.data(), b.lengths.data(),
+ b.formats.data(), 0),
&PQclear};
verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK || PQresultStatus(res.get()) == PGRES_TUPLES_OK,
name, conn);
@@ -54,7 +54,7 @@ namespace MyGrate::Output::Pq {
return i->second;
}
auto nam {scprintf<"pst%0lx">(c->stmts.size())};
- ResPtr res {PQprepare(c->conn.get(), nam.c_str(), q, (int)n, nullptr), PQclear};
+ ResPtr res {PQprepare(c->conn.get(), nam.c_str(), q, static_cast<int>(n), nullptr), PQclear};
verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q, c->conn.get());
return c->stmts.emplace(q, std::move(nam)).first->second;
}
diff --git a/lib/output/pq/writePqCopyStrm.cpp b/lib/output/pq/writePqCopyStrm.cpp
index 984b4fd..9d52a46 100644
--- a/lib/output/pq/writePqCopyStrm.cpp
+++ b/lib/output/pq/writePqCopyStrm.cpp
@@ -84,7 +84,7 @@ namespace MyGrate::Output::Pq {
}()};
fputs("\\\\x", out);
std::for_each(v.begin(), v.end(), [this](auto b) {
- fwrite(hex[(uint8_t)b].data(), 2, 1, out);
+ fwrite(hex[static_cast<uint8_t>(b)].data(), 2, 1, out);
});
}
}