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

Function appendFromBlob

src/jrd/SysFunction.cpp:2368–2399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2366
2367
2368static void appendFromBlob(thread_db* tdbb, jrd_tra* transaction, blb* blob,
2369 const dsc* blobDsc, const dsc* srcDsc)
2370{
2371 if (!srcDsc->dsc_address)
2372 return;
2373
2374 bid* srcBlobID = (bid*)srcDsc->dsc_address;
2375 if (srcBlobID->isEmpty())
2376 return;
2377
2378 if (memcmp(blobDsc->dsc_address, srcDsc->dsc_address, sizeof(bid)) == 0)
2379 status_exception::raise(Arg::Gds(isc_random) << Arg::Str("Can not append blob to itself"));
2380
2381 UCharBuffer bpb;
2382 BLB_gen_bpb_from_descs(srcDsc, blobDsc, bpb);
2383
2384 AutoBlb srcBlob(tdbb, blb::open2(tdbb, transaction, srcBlobID, bpb.getCount(), bpb.begin()));
2385
2386 Database* dbb = tdbb->getDatabase();
2387
2388 HalfStaticArray<UCHAR, BUFFER_LARGE> buffer;
2389 const SLONG buffSize = (srcBlob->getLevel() == 0) ?
2390 MAX(BUFFER_LARGE, srcBlob->blb_length) : dbb->dbb_page_size - BLP_SIZE;
2391
2392 UCHAR* buff = buffer.getBuffer(buffSize);
2393 while (!(srcBlob->blb_flags & BLB_eof))
2394 {
2395 const SLONG len = srcBlob->BLB_get_data(tdbb, buff, buffSize, false);
2396 if (len)
2397 blob->BLB_put_data(tdbb, buff, len);
2398 }
2399}
2400
2401
2402dsc* evlBlobAppend(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,

Callers 1

evlBlobAppendFunction · 0.85

Calls 12

raiseFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
BLB_gen_bpb_from_descsFunction · 0.85
getDatabaseMethod · 0.80
getLevelMethod · 0.80
BLB_get_dataMethod · 0.80
BLB_put_dataMethod · 0.80
isEmptyMethod · 0.45
getCountMethod · 0.45
beginMethod · 0.45
getBufferMethod · 0.45

Tested by

no test coverage detected