]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
support reconfigure
authorRazvan Becheriu <razvan@isc.org>
Thu, 24 Oct 2019 11:03:16 +0000 (14:03 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 6 Nov 2019 17:32:51 +0000 (19:32 +0200)
src/lib/pgsql/pgsql_connection.cc

index a2d7e6c56ed7c51cc736378981f1399446b1cf1c..b311b366502d31716bc70b34f2ea2a58b8ff0618 100644 (file)
@@ -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: "