diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-31 04:59:00 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-31 04:59:00 +0000 |
commit | 4013f18f0e9f257e6c0d7ffecdec3cfc9bf0db0d (patch) | |
tree | d8e89ed8329c9367bf32c59584f6b659b81584ec /libpqpp/pq-connection.cpp | |
parent | More complex approach to setting tables to unlogged to handle foreign key dep... (diff) | |
download | libdbpp-postgresql-4013f18f0e9f257e6c0d7ffecdec3cfc9bf0db0d.tar.bz2 libdbpp-postgresql-4013f18f0e9f257e6c0d7ffecdec3cfc9bf0db0d.tar.xz libdbpp-postgresql-4013f18f0e9f257e6c0d7ffecdec3cfc9bf0db0d.zip |
Do lots more work with compile time formatter instead runtime formatters
Diffstat (limited to 'libpqpp/pq-connection.cpp')
-rw-r--r-- | libpqpp/pq-connection.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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 <unistd.h> #include <poll.h> #include <boost/assert.hpp> +#include <compileTimeFormatter.h> 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 |