]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#549] not strictly related: fix wrong column count for the options tables
authorAndrei Pavel <andrei@isc.org>
Wed, 5 Apr 2023 12:11:13 +0000 (15:11 +0300)
committerAndrei Pavel <andrei@isc.org>
Wed, 19 Apr 2023 20:56:01 +0000 (23:56 +0300)
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.

src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/pgsql_host_data_source.cc

index 310421e3a74168b7202b46bc11bb0d54e76ff49f..a45c21ca74694b375c3418b34e8a2eece70b9f17 100644 (file)
@@ -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.
index 5ab5cebf2560e02bd585a393f24616e88c6b240c..46c4497b68f14bb22824590b50a435c7a30748d2 100644 (file)
@@ -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.