read external blob (src), store it as temporary local blob and put local blob_id into dst
| 2425 | |
| 2426 | // read external blob (src), store it as temporary local blob and put local blob_id into dst |
| 2427 | void Statement::getExtBlob(thread_db* tdbb, const dsc& src, dsc& dst) |
| 2428 | { |
| 2429 | blb* destBlob = NULL; |
| 2430 | AutoPtr<Blob> extBlob(m_connection.createBlob()); |
| 2431 | try |
| 2432 | { |
| 2433 | extBlob->open(tdbb, *m_transaction, src, NULL); |
| 2434 | |
| 2435 | Request* request = tdbb->getRequest(); |
| 2436 | const UCHAR bpb[] = {isc_bpb_version1, isc_bpb_storage, 1, isc_bpb_storage_temp}; |
| 2437 | bid* localBlobID = (bid*) dst.dsc_address; |
| 2438 | destBlob = blb::create2(tdbb, request->req_transaction, localBlobID, sizeof(bpb), bpb); |
| 2439 | |
| 2440 | // hvlad ? |
| 2441 | destBlob->blb_sub_type = src.getBlobSubType(); |
| 2442 | destBlob->blb_charset = src.getCharSet(); |
| 2443 | |
| 2444 | Array<UCHAR> buffer; |
| 2445 | const int bufSize = 32 * 1024 - 2/*input->getMaxSegment()*/; |
| 2446 | UCHAR* buff = buffer.getBuffer(bufSize); |
| 2447 | |
| 2448 | while (true) |
| 2449 | { |
| 2450 | const USHORT length = extBlob->read(tdbb, buff, bufSize); |
| 2451 | if (!length) |
| 2452 | break; |
| 2453 | |
| 2454 | destBlob->BLB_put_segment(tdbb, buff, length); |
| 2455 | } |
| 2456 | |
| 2457 | extBlob->close(tdbb); |
| 2458 | destBlob->BLB_close(tdbb); |
| 2459 | } |
| 2460 | catch (const Exception&) |
| 2461 | { |
| 2462 | extBlob->close(tdbb); |
| 2463 | if (destBlob) { |
| 2464 | destBlob->BLB_cancel(tdbb); |
| 2465 | } |
| 2466 | throw; |
| 2467 | } |
| 2468 | } |
| 2469 | |
| 2470 | // read local blob, store it as external blob and put external blob_id in dst |
| 2471 | void Statement::putExtBlob(thread_db* tdbb, dsc& src, dsc& dst) |
nothing calls this directly
no test coverage detected