]> granicus.if.org Git - pdns/commitdiff
gpgsql: make statement names actually unique
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Sat, 21 Jan 2017 22:13:57 +0000 (23:13 +0100)
committerChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Sat, 21 Jan 2017 22:13:57 +0000 (23:13 +0100)
modules/gpgsqlbackend/spgsql.cc

index ed80d4c53bc3bbeaf5a269339d692a6f15da0f3f..ca698adcbc9e58266522e4fbb04caaef5d5d07c6 100644 (file)
@@ -214,11 +214,9 @@ private:
   }
 
   void prepareStatement() {
-    struct timeval tv;
     if (d_prepared) return;
-    // prepare a statement
-    gettimeofday(&tv,NULL);
-    this->d_stmt = string("stmt") + std::to_string(tv.tv_sec) + std::to_string(tv.tv_usec);
+    // prepare a statement; name must be unique per session.
+    this->d_stmt = string("stmt") + std::to_string((uintptr_t)this);
     PGresult* res = PQprepare(d_db(), d_stmt.c_str(), d_query.c_str(), d_nparams, NULL);
     ExecStatusType status = PQresultStatus(res);
     string errmsg(PQresultErrorMessage(res));