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

Function evlHash

src/jrd/SysFunction.cpp:5073–5129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5071
5072
5073dsc* evlHash(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
5074 impure_value* impure)
5075{
5076 fb_assert(args.getCount() >= 1);
5077
5078 Request* request = tdbb->getRequest();
5079
5080 const dsc* value = EVL_expr(tdbb, request, args[0]);
5081 if (request->req_flags & req_null) // return NULL if value is NULL
5082 return NULL;
5083
5084 AutoPtr<HashContext> hashContext;
5085 MemoryPool& pool = *request->req_pool;
5086
5087 if (args.getCount() >= 2)
5088 {
5089 const dsc* algorithmDesc = EVL_expr(tdbb, request, args[1]);
5090 if (request->req_flags & req_null) // return NULL if algorithm is NULL
5091 return NULL;
5092
5093 const HashAlgorithmDescriptor* d = getHashAlgorithmDesc(tdbb, function, algorithmDesc);
5094 hashContext.reset(d->create(pool));
5095 }
5096 else
5097 {
5098 hashContext.reset(FB_NEW_POOL(pool) WeakHashContext());
5099 impure->vlu_misc.vlu_int64 = 0;
5100 }
5101
5102 if (value->isBlob())
5103 {
5104 UCHAR buffer[BUFFER_LARGE];
5105 blb* blob = blb::open(tdbb, tdbb->getRequest()->req_transaction,
5106 reinterpret_cast<bid*>(value->dsc_address));
5107
5108 while (!(blob->blb_flags & BLB_eof))
5109 {
5110 const ULONG length = blob->BLB_get_data(tdbb, buffer, sizeof(buffer), false);
5111 hashContext->update(buffer, length);
5112 }
5113
5114 blob->BLB_close(tdbb);
5115 }
5116 else
5117 {
5118 UCHAR* address;
5119 MoveBuffer buffer;
5120 const ULONG length = MOV_make_string2(tdbb, value, value->getTextType(), &address, buffer, false);
5121 hashContext->update(address, length);
5122 }
5123
5124 dsc result;
5125 hashContext->finish(result);
5126 EVL_make_value(tdbb, &result, impure);
5127
5128 return &impure->vlu_desc;
5129}
5130

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
getHashAlgorithmDescFunction · 0.85
WeakHashContextClass · 0.85
MOV_make_string2Function · 0.85
EVL_make_valueFunction · 0.85
isBlobMethod · 0.80
BLB_get_dataMethod · 0.80
BLB_closeMethod · 0.80
getTextTypeMethod · 0.80
openFunction · 0.50
getCountMethod · 0.45
getRequestMethod · 0.45

Tested by

no test coverage detected