]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2445] fix PgSqlLeaseMgr::isJsonSupported() from always returning true
authorAndrei Pavel <andrei@isc.org>
Tue, 28 Jun 2022 07:46:30 +0000 (10:46 +0300)
committerAndrei Pavel <andrei@isc.org>
Wed, 29 Jun 2022 12:51:28 +0000 (15:51 +0300)
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc

index 045ce7f23811befff0f9d048ff1fc175e48f2da2..27f3aeb1d06719861b0299c9d53b699f9d308b6c 100644 (file)
@@ -2342,8 +2342,8 @@ PgSqlLeaseMgr::isJsonSupported() const {
                                  0, 0, 0, 0, 0));
     ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
 
-    bool const json_supported(PgSqlExchange::getRawColumnValue(r, 0, 0));
-    return json_supported;
+    std::string const json_supported(PgSqlExchange::getRawColumnValue(r, 0, 0));
+    return json_supported == "t";
 }
 
 LeaseStatsQueryPtr
index 818cc3d256ba9c15914f94452b0e68ae4e6c27f0..f07876e1d227400ab53389e5ac352e445538c272 100644 (file)
@@ -1085,14 +1085,26 @@ TEST_F(PgSqlLeaseMgrTest, checkLimits) {
     if (!LeaseMgrFactory::instance().isJsonSupported()) {
         ASSERT_THROW_MSG(LeaseMgrFactory::instance().checkLimits4(
             isc::data::Element::createMap()), isc::db::DbOperationError,
-            "unable to set up for storing all results for "
-            "<SELECT checkLease4Limits(?)>, reason: FUNCTION "
-            "keatest.JSON_EXTRACT does not exist (error code 1305)");
+            "Statement exec failed for: check_lease4_limits, status: 7sqlstate:[ 42883 ], "
+            "reason: ERROR:  operator does not exist: json -> unknown\n"
+            "LINE 1: ...* FROM JSON_ARRAY_ELEMENTS(json_cast(user_context)->'ISC'->'...\n"
+            "                                                             ^\n"
+            "HINT:  No operator matches the given name and argument type(s). "
+            "You might need to add explicit type casts.\n"
+            "QUERY:  SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(user_context)"
+            "->'ISC'->'limits'->'client-classes')\n"
+            "CONTEXT:  PL/pgSQL function checklease4limits(text) line 10 at FOR over SELECT rows\n");
         ASSERT_THROW_MSG(LeaseMgrFactory::instance().checkLimits6(
             isc::data::Element::createMap()), isc::db::DbOperationError,
-            "unable to set up for storing all results for "
-            "<SELECT checkLease6Limits(?)>, reason: FUNCTION "
-            "keatest.JSON_EXTRACT does not exist (error code 1305)");
+            "Statement exec failed for: check_lease6_limits, status: 7sqlstate:[ 42883 ], "
+            "reason: ERROR:  operator does not exist: json -> unknown\n"
+            "LINE 1: ...* FROM JSON_ARRAY_ELEMENTS(json_cast(user_context)->'ISC'->'...\n"
+            "                                                             ^\n"
+            "HINT:  No operator matches the given name and argument type(s). "
+            "You might need to add explicit type casts.\n"
+            "QUERY:  SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(user_context)"
+            "->'ISC'->'limits'->'client-classes')\n"
+            "CONTEXT:  PL/pgSQL function checklease6limits(text) line 10 at FOR over SELECT rows\n");
         return;
     }