Skip to content

Commit

Permalink
Postfix for #8304: Wrong results using minvalue/maxvalue in join cond…
Browse files Browse the repository at this point in the history
…ition. It should fix regression #8440: Firebird 5.0.2 - wrong result for MINVALUE/MAXVALUE with string arguments.
  • Loading branch information
dyemanov committed Feb 18, 2025
1 parent 29b2499 commit adc49ed
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/jrd/SysFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5494,10 +5494,37 @@ dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValu
}

DataTypeUtil(tdbb).makeFromList(&impure->vlu_desc, function->name, argTypes.getCount(), argTypes.begin());
impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;

if (impure->vlu_desc.isText())
{
const USHORT length = impure->vlu_desc.dsc_length;

// Allocate a string block of sufficient size

auto string = impure->vlu_string;

if (string && string->str_length < length)
{
delete string;
string = nullptr;
}

if (!string)
{
string = impure->vlu_string = FB_NEW_RPT(*tdbb->getDefaultPool(), length) VaryingString();
string->str_length = length;
}

impure->vlu_desc.dsc_address = string->str_data;
}
else
impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;

MOV_move(tdbb, result, &impure->vlu_desc);

if (impure->vlu_desc.dsc_dtype == dtype_text)
INTL_adjust_text_descriptor(tdbb, &impure->vlu_desc);

return &impure->vlu_desc;
}

Expand Down

0 comments on commit adc49ed

Please sign in to comment.