2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[#2445] fix PgSqlLeaseMgr::isJsonSupported() from always returning true

This commit is contained in:
Andrei Pavel
2022-06-28 10:46:30 +03:00
parent b393239079
commit e844a8b7c6
2 changed files with 20 additions and 8 deletions

View 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

View 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;
}