From 9758d7cdc98f0d948581fb5630c33e98e4b52855 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 6 Jan 2017 02:11:57 +0000 Subject: Use SQL hash for prepared statement names, increases reuse and avoids random reuse --- libpqpp/pq-command.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libpqpp/pq-command.cpp') diff --git a/libpqpp/pq-command.cpp b/libpqpp/pq-command.cpp index a6259df..5ff83f0 100644 --- a/libpqpp/pq-command.cpp +++ b/libpqpp/pq-command.cpp @@ -5,10 +5,11 @@ #include #include -AdHocFormatter(PQCommondStatement, "pStatement_%?_%?"); -PQ::Command::Command(Connection * conn, const std::string & sql, unsigned int no) : +AdHocFormatter(PQCommondStatement, "pStatement_id%?"); +PQ::Command::Command(Connection * conn, const std::string & sql, const DB::CommandOptions * opts) : DB::Command(sql), - stmntName(PQCommondStatement::get(no, this)), + hash(opts && opts->hash ? *opts->hash : std::hash()(sql)), + stmntName(PQCommondStatement::get(hash)), c(conn) { } -- cgit v1.2.3