Skip to content

Commit cce373f

Browse files
committed
Postfix for #8304: Wrong results using minvalue/maxvalue in join condition. It should fix regression #8440: Firebird 5.0.2 - wrong result for MINVALUE/MAXVALUE with string arguments.
1 parent 9cac45a commit cce373f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/jrd/SysFunction.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5409,10 +5409,37 @@ dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValu
54095409
}
54105410

54115411
DataTypeUtil(tdbb).makeFromList(&impure->vlu_desc, function->name, argTypes.getCount(), argTypes.begin());
5412-
impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;
5412+
5413+
if (impure->vlu_desc.isText())
5414+
{
5415+
const USHORT length = impure->vlu_desc.dsc_length;
5416+
5417+
// Allocate a string block of sufficient size
5418+
5419+
auto string = impure->vlu_string;
5420+
5421+
if (string && string->str_length < length)
5422+
{
5423+
delete string;
5424+
string = nullptr;
5425+
}
5426+
5427+
if (!string)
5428+
{
5429+
string = impure->vlu_string = FB_NEW_RPT(*tdbb->getDefaultPool(), length) VaryingString();
5430+
string->str_length = length;
5431+
}
5432+
5433+
impure->vlu_desc.dsc_address = string->str_data;
5434+
}
5435+
else
5436+
impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;
54135437

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

5440+
if (impure->vlu_desc.dsc_dtype == dtype_text)
5441+
INTL_adjust_text_descriptor(tdbb, &impure->vlu_desc);
5442+
54165443
return &impure->vlu_desc;
54175444
}
54185445

0 commit comments

Comments
 (0)