From: Razvan Becheriu Date: Thu, 24 Oct 2019 11:03:16 +0000 (+0300) Subject: support reconfigure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75ff4f9cb606ce3287ac1d5e91cc54bdeee5feb6;p=thirdparty%2Fkea.git support reconfigure --- diff --git a/src/lib/pgsql/pgsql_connection.cc b/src/lib/pgsql/pgsql_connection.cc index a2d7e6c56e..b311b36650 100644 --- a/src/lib/pgsql/pgsql_connection.cc +++ b/src/lib/pgsql/pgsql_connection.cc @@ -38,6 +38,7 @@ const int PGSQL_DEFAULT_CONNECTION_TIMEOUT = 5; // seconds const char PgSqlConnection::DUPLICATE_KEY[] = ERRCODE_UNIQUE_VIOLATION; void +<<<<<<< HEAD PgSqlHolder::setConnection(PGconn* connection) { // clear prepared statements associated to current connection clearPrepared(); @@ -56,6 +57,10 @@ PgSqlHolder::setConnection(PGconn* connection) { void PgSqlHolder::clearPrepared() { if (pgsql_ != NULL) { +======= +PgSqlHolder::clearPrepared() { + if (pgconn_ != NULL) { +>>>>>>> support reconfigure // Deallocate the prepared queries. if (PQstatus(pgsql_) == CONNECTION_OK) { PgSqlResult r(PQexec(pgsql_, "DEALLOCATE all")); @@ -68,6 +73,17 @@ PgSqlHolder::clearPrepared() { } } +void +PgSqlHolder::setConnection(PGconn* connection) { + clearPrepared(); + if (pgconn_ != NULL) { + PQfinish(pgconn_); + } + pgconn_ = connection; + connected_ = false; + prepared_ = false; +} + void PgSqlHolder::openDatabase(PgSqlConnection& connection) { // return if holder has already called openDatabase @@ -98,7 +114,11 @@ PgSqlHolder::prepareStatements(PgSqlConnection& connection) { // Prepare all statements queries with all known fields datatype for (auto it = connection.statements_.begin(); it != connection.statements_.end(); ++it) { +<<<<<<< HEAD PgSqlResult r(PQprepare(pgsql_, (*it)->name, (*it)->text, +======= + PgSqlResult r(PQprepare(pgconn_, (*it)->name, (*it)->text, +>>>>>>> support reconfigure (*it)->nbparams, (*it)->types)); if (PQresultStatus(r) != PGRES_COMMAND_OK) { isc_throw(DbOperationError, "unable to prepare PostgreSQL statement: "