From 4013f18f0e9f257e6c0d7ffecdec3cfc9bf0db0d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 31 Dec 2016 04:59:00 +0000 Subject: Do lots more work with compile time formatter instead runtime formatters --- libpqpp/pq-connection.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libpqpp/pq-connection.cpp') diff --git a/libpqpp/pq-connection.cpp b/libpqpp/pq-connection.cpp index 078272e..b7360e0 100644 --- a/libpqpp/pq-connection.cpp +++ b/libpqpp/pq-connection.cpp @@ -6,6 +6,7 @@ #include #include #include +#include NAMEDFACTORY("postgresql", PQ::Connection, DB::ConnectionFactory); @@ -137,12 +138,11 @@ PQ::Connection::checkResultFree(PGresult * res, int expected, int alt) const PQclear(res); } +AdHocFormatter(PQConnectionCopyFrom, "COPY %? FROM STDIN %?"); void PQ::Connection::beginBulkUpload(const char * table, const char * extra) { - char buf[BUFSIZ]; - snprintf(buf, BUFSIZ, "COPY %s FROM STDIN %s", table, extra); - checkResultFree(PQexec(conn, buf), PGRES_COPY_IN); + checkResultFree(PQexec(conn, PQConnectionCopyFrom::get(table, extra).c_str()), PGRES_COPY_IN); } void -- cgit v1.2.3