]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1008] Updated pgsql_host_data_source.cc
authorFrancis Dupont <fdupont@isc.org>
Tue, 3 Dec 2019 10:00:47 +0000 (11:00 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 4 Dec 2019 13:33:09 +0000 (14:33 +0100)
src/lib/dhcpsrv/pgsql_host_data_source.cc

index 7ea6f61e6b8e0308e7d25515cb4c8daaeca351df..d23516927d31c2254bcb0e1fdd58fba6e1f50c8f 100644 (file)
@@ -1442,7 +1442,7 @@ public:
     ///        has failed.
     std::pair<uint32_t, uint32_t> getVersion() const;
 
-    /// @brief Pointer to the object representing an exchange which
+    /// @Brief Pointer to the object representing an exchange which
     /// can be used to retrieve hosts and DHCPv4 options.
     boost::shared_ptr<PgSqlHostWithOptionsExchange> host_exchange_;
 
@@ -1464,6 +1464,9 @@ public:
     /// or dhcp6_options table.
     boost::shared_ptr<PgSqlOptionExchange> host_option_exchange_;
 
+    /// @brief The parameters
+    PgSqlConnection::ParameterMap parameters_;
+
     /// @brief PgSQL connection
     PgSqlConnection conn_;
 
@@ -1913,12 +1916,10 @@ PgSqlHostDataSourceImpl(const PgSqlConnection::ParameterMap& parameters)
                                                      DHCP4_AND_DHCP6)),
       host_ipv6_reservation_exchange_(new PgSqlIPv6ReservationExchange()),
       host_option_exchange_(new PgSqlOptionExchange()),
+      parameters_(parameters),
       conn_(parameters),
       is_readonly_(false) {
 
-    // Open the database.
-    conn_.openDatabase();
-
     // Validate the schema version first.
     std::pair<uint32_t, uint32_t> code_version(PG_SCHEMA_VERSION_MAJOR,
                                                PG_SCHEMA_VERSION_MINOR);
@@ -1931,6 +1932,9 @@ PgSqlHostDataSourceImpl(const PgSqlConnection::ParameterMap& parameters)
                       << db_version.second);
     }
 
+    // Open the database.
+    conn_.openDatabase();
+
     // Now prepare the SQL statements.
     conn_.prepareStatements(tagged_statements.begin(),
                             tagged_statements.begin() + WRITE_STMTS_BEGIN);