From: Andrei Pavel Date: Wed, 5 Apr 2023 12:11:13 +0000 (+0300) Subject: [#549] not strictly related: fix wrong column count for the options tables X-Git-Tag: Kea-2.3.7~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1aa48a32a8a07380b25763b53c5ec7cb59c0e416;p=thirdparty%2Fkea.git [#549] not strictly related: fix wrong column count for the options tables There's no point in having columns with predetermined values added to a database exchange object. There's an extra column accounted for in these columns called scope_id that always has value 3. This bug has no effect. The extra scope_id is ignored by PgSqlOptionExchange, but in the MySQL counterpart, a bogus value is sent to the MySQL driver which itself seems to ignore it. The effects of this bug becomes visible if you try to add the bind vector, you get an error about not being able to bind the values, because they're one off starting with the scope_id. --- diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index 310421e3a7..a45c21ca74 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -1761,8 +1761,8 @@ private: class MySqlOptionExchange { private: - /// @brief Number of columns in the tables holding options. - static const size_t OPTION_COLUMNS = 11; + /// @brief Number of columns in the option tables holding bindable values. + static const size_t OPTION_COLUMNS = 10; public: @@ -1773,7 +1773,7 @@ public: user_context_(), user_context_len_(0), subnet_id_(SUBNET_ID_UNUSED), host_id_(0), option_() { - BOOST_STATIC_ASSERT(10 < OPTION_COLUMNS); + BOOST_STATIC_ASSERT(10 <= OPTION_COLUMNS); } /// @brief Creates binding array to insert option data into database. diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc index 5ab5cebf25..46c4497b68 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.cc +++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc @@ -1179,10 +1179,9 @@ private: static const int DHCP_CLIENT_CLASS_COL = 8; static const int DHCP_SUBNET_ID_COL = 9; static const int HOST_ID_COL = 10; - static const int SCOPE_ID_COL = 11; - /// @brief Number of columns in the tables holding options. - static const size_t OPTION_COLUMNS = 12; + /// @brief Number of columns in the option tables holding bindable values. + static const size_t OPTION_COLUMNS = 11; public: @@ -1201,9 +1200,8 @@ public: columns_[DHCP_CLIENT_CLASS_COL] = "dhcp_client_class"; columns_[DHCP_SUBNET_ID_COL] = "dhcp_subnet_id"; columns_[HOST_ID_COL] = "host_id"; - columns_[SCOPE_ID_COL] = "scope_id"; - BOOST_STATIC_ASSERT(11 < OPTION_COLUMNS); + BOOST_STATIC_ASSERT(11 <= OPTION_COLUMNS); } /// @brief Creates binding array to insert option data into database.