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

Method putExtBlob

src/jrd/extds/ExtDS.cpp:2471–2512  ·  view source on GitHub ↗

read local blob, store it as external blob and put external blob_id in dst

Source from the content-addressed store, hash-verified

2469
2470// read local blob, store it as external blob and put external blob_id in dst
2471void Statement::putExtBlob(thread_db* tdbb, dsc& src, dsc& dst)
2472{
2473 blb* srcBlob = NULL;
2474 AutoPtr<Blob> extBlob(m_connection.createBlob());
2475 try
2476 {
2477 extBlob->create(tdbb, *m_transaction, dst, NULL);
2478
2479 Request* request = tdbb->getRequest();
2480 bid* srcBid = (bid*) src.dsc_address;
2481
2482 UCharBuffer bpb;
2483 BLB_gen_bpb_from_descs(&src, &dst, bpb);
2484 srcBlob = blb::open2(tdbb, request->req_transaction, srcBid, bpb.getCount(), bpb.begin());
2485
2486 HalfStaticArray<UCHAR, 2048> buffer;
2487 const int bufSize = srcBlob->getMaxSegment();
2488 UCHAR* buff = buffer.getBuffer(bufSize);
2489
2490 while (true)
2491 {
2492 USHORT length = srcBlob->BLB_get_segment(tdbb, buff, srcBlob->getMaxSegment());
2493 if (srcBlob->blb_flags & BLB_eof) {
2494 break;
2495 }
2496
2497 extBlob->write(tdbb, buff, length);
2498 }
2499
2500 srcBlob->BLB_close(tdbb);
2501 srcBlob = NULL;
2502 extBlob->close(tdbb);
2503 }
2504 catch (const Exception&)
2505 {
2506 if (srcBlob) {
2507 srcBlob->BLB_close(tdbb);
2508 }
2509 extBlob->cancel(tdbb);
2510 throw;
2511 }
2512}
2513
2514void Statement::clearNames()
2515{

Callers

nothing calls this directly

Calls 13

BLB_gen_bpb_from_descsFunction · 0.85
getMaxSegmentMethod · 0.80
BLB_get_segmentMethod · 0.80
BLB_closeMethod · 0.80
createBlobMethod · 0.45
createMethod · 0.45
getRequestMethod · 0.45
getCountMethod · 0.45
beginMethod · 0.45
getBufferMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected