MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / evlMaxMinValue

Function evlMaxMinValue

src/jrd/SysFunction.cpp:5523–5596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5521
5522
5523dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
5524 impure_value* impure)
5525{
5526 fb_assert(args.getCount() >= 1);
5527 fb_assert(function->misc != NULL);
5528
5529 const auto request = tdbb->getRequest();
5530 HalfStaticArray<const dsc*, 2> argTypes(args.getCount());
5531 dsc* result = nullptr;
5532
5533 for (FB_SIZE_T i = 0; i < args.getCount(); ++i)
5534 {
5535 const auto value = EVL_expr(tdbb, request, args[i]);
5536 if (request->req_flags & req_null) // return NULL if value is NULL
5537 return nullptr;
5538
5539 argTypes.add(value);
5540
5541 if (i == 0)
5542 result = value;
5543 else
5544 {
5545 switch ((Function)(IPTR) function->misc)
5546 {
5547 case funMaxValue:
5548 if (MOV_compare(tdbb, value, result) > 0)
5549 result = value;
5550 break;
5551
5552 case funMinValue:
5553 if (MOV_compare(tdbb, value, result) < 0)
5554 result = value;
5555 break;
5556
5557 default:
5558 fb_assert(false);
5559 }
5560 }
5561 }
5562
5563 DataTypeUtil(tdbb).makeFromList(&impure->vlu_desc, function->name, argTypes.getCount(), argTypes.begin());
5564
5565 if (impure->vlu_desc.isText())
5566 {
5567 const USHORT length = impure->vlu_desc.dsc_length;
5568
5569 // Allocate a string block of sufficient size
5570
5571 auto string = impure->vlu_string;
5572
5573 if (string && string->str_length < length)
5574 {
5575 delete string;
5576 string = nullptr;
5577 }
5578
5579 if (!string)
5580 {

Callers

nothing calls this directly

Calls 13

EVL_exprFunction · 0.85
MOV_compareFunction · 0.85
DataTypeUtilClass · 0.85
MOV_moveFunction · 0.85
makeFromListMethod · 0.80
isTextMethod · 0.80
VaryingStringClass · 0.70
getCountMethod · 0.45
getRequestMethod · 0.45
addMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected