From 1c3dc4393570cdf01f8e995999ee99cfd8233620 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Sun, 3 Nov 2024 21:23:02 -0300 Subject: [PATCH] Fix #8304 - Wrong results using minvalue/maxvalue in join condition. --- src/jrd/SysFunction.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/jrd/SysFunction.cpp b/src/jrd/SysFunction.cpp index 0e37600536..ac47df0e08 100644 --- a/src/jrd/SysFunction.cpp +++ b/src/jrd/SysFunction.cpp @@ -5470,19 +5470,22 @@ dsc* evlMakeDbkey(Jrd::thread_db* tdbb, const SysFunction* function, const NestV dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, - impure_value*) + impure_value* impure) { fb_assert(args.getCount() >= 1); fb_assert(function->misc != NULL); - Request* request = tdbb->getRequest(); - dsc* result = NULL; + const auto request = tdbb->getRequest(); + HalfStaticArray argTypes(args.getCount()); + dsc* result = nullptr; for (FB_SIZE_T i = 0; i < args.getCount(); ++i) { - dsc* value = EVL_expr(tdbb, request, args[i]); + const auto value = EVL_expr(tdbb, request, args[i]); if (request->req_flags & req_null) // return NULL if value is NULL - return NULL; + return nullptr; + + argTypes.add(value); if (i == 0) result = value; @@ -5506,7 +5509,12 @@ dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValu } } - return result; + DataTypeUtil(tdbb).makeFromList(&impure->vlu_desc, function->name, argTypes.getCount(), argTypes.begin()); + impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc; + + MOV_move(tdbb, result, &impure->vlu_desc); + + return &impure->vlu_desc; }