diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-04 02:00:04 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-01-04 02:00:04 +0000 |
commit | f9fc8240229cd1f059bfc56eb027aec11fec6b4c (patch) | |
tree | c276986ac80870167d594d5d8229824317d38582 /libpqpp/pq-prepared.cpp | |
parent | Tidy clearing of PGresults (diff) | |
download | libdbpp-postgresql-f9fc8240229cd1f059bfc56eb027aec11fec6b4c.tar.bz2 libdbpp-postgresql-f9fc8240229cd1f059bfc56eb027aec11fec6b4c.tar.xz libdbpp-postgresql-f9fc8240229cd1f059bfc56eb027aec11fec6b4c.zip |
C++ify the SQL preparer and skip it if no variables are being bound
Diffstat (limited to 'libpqpp/pq-prepared.cpp')
-rw-r--r-- | libpqpp/pq-prepared.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libpqpp/pq-prepared.cpp b/libpqpp/pq-prepared.cpp index bdf2a7d..8e6cea5 100644 --- a/libpqpp/pq-prepared.cpp +++ b/libpqpp/pq-prepared.cpp @@ -19,11 +19,10 @@ PQ::PreparedStatement::prepare() const if (i != c->preparedStatements.end()) { return (pstmt = i->second.c_str()); } - std::string psql; - psql.reserve(sql.length() + 20); + std::stringstream psql; prepareSql(psql, sql); c->checkResultFree(PQprepare( - c->conn, stmntName.c_str(), psql.c_str(), values.size(), NULL), PGRES_COMMAND_OK); + c->conn, stmntName.c_str(), psql.str().c_str(), values.size(), NULL), PGRES_COMMAND_OK); return (pstmt = c->preparedStatements.insert({hash, stmntName}).first->second.c_str()); } |