Skip to content

Commit 9c7eeed

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 201a451 commit 9c7eeed

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
@@ -5511,10 +5511,37 @@ dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValu
55115511
}
55125512

55135513
DataTypeUtil(tdbb).makeFromList(&impure->vlu_desc, function->name, argTypes.getCount(), argTypes.begin());
5514-
impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;
5514+
5515+
if (impure->vlu_desc.isText())
5516+
{
5517+
const USHORT length = impure->vlu_desc.dsc_length;
5518+
5519+
// Allocate a string block of sufficient size
5520+
5521+
auto string = impure->vlu_string;
5522+
5523+
if (string && string->str_length < length)
5524+
{
5525+
delete string;
5526+
string = nullptr;
5527+
}
5528+
5529+
if (!string)
5530+
{
5531+
string = impure->vlu_string = FB_NEW_RPT(*tdbb->getDefaultPool(), length) VaryingString();
5532+
string->str_length = length;
5533+
}
5534+
5535+
impure->vlu_desc.dsc_address = string->str_data;
5536+
}
5537+
else
5538+
impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;
55155539

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

5542+
if (impure->vlu_desc.dsc_dtype == dtype_text)
5543+
INTL_adjust_text_descriptor(tdbb, &impure->vlu_desc);
5544+
55185545
return &impure->vlu_desc;
55195546
}
55205547

0 commit comments

Comments
 (0)