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

Function evlRight

src/jrd/SysFunction.cpp:6484–6534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6482
6483
6484dsc* evlRight(thread_db* tdbb, const SysFunction*, const NestValueArray& args,
6485 impure_value* impure)
6486{
6487 fb_assert(args.getCount() == 2);
6488
6489 Request* request = tdbb->getRequest();
6490
6491 const dsc* value = EVL_expr(tdbb, request, args[0]);
6492 if (request->req_flags & req_null) // return NULL if value is NULL
6493 return NULL;
6494
6495 const dsc* len = EVL_expr(tdbb, request, args[1]);
6496 if (request->req_flags & req_null) // return NULL if len is NULL
6497 return NULL;
6498
6499 CharSet* charSet = INTL_charset_lookup(tdbb, value->getCharSet());
6500 SLONG start;
6501
6502 if (value->isBlob())
6503 {
6504 blb* blob = blb::open(tdbb, tdbb->getRequest()->req_transaction,
6505 reinterpret_cast<bid*>(value->dsc_address));
6506
6507 if (charSet->isMultiByte())
6508 {
6509 HalfStaticArray<UCHAR, BUFFER_LARGE> buffer;
6510 SLONG length = blob->BLB_get_data(tdbb, buffer.getBuffer(blob->blb_length),
6511 blob->blb_length, false);
6512 start = charSet->length(length, buffer.begin(), true);
6513 }
6514 else
6515 start = blob->blb_length / charSet->maxBytesPerChar();
6516
6517 blob->BLB_close(tdbb);
6518 }
6519 else
6520 {
6521 MoveBuffer temp;
6522 UCHAR* p;
6523 start = MOV_make_string2(tdbb, value, value->getTextType(), &p, temp);
6524 start = charSet->length(start, p, true);
6525 }
6526
6527 start -= MOV_get_long(tdbb, len, 0);
6528 start = MAX(0, start);
6529
6530 dsc startDsc;
6531 startDsc.makeLong(0, &start);
6532
6533 return SubstringNode::perform(tdbb, impure, value, &startDsc, len);
6534}
6535
6536
6537dsc* evlRound(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
INTL_charset_lookupFunction · 0.85
MOV_make_string2Function · 0.85
MOV_get_longFunction · 0.85
isBlobMethod · 0.80
isMultiByteMethod · 0.80
BLB_get_dataMethod · 0.80
BLB_closeMethod · 0.80
getTextTypeMethod · 0.80
makeLongMethod · 0.80
openFunction · 0.50
getCountMethod · 0.45

Tested by

no test coverage detected