| 2400 | |
| 2401 | |
| 2402 | dsc* evlBlobAppend(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, |
| 2403 | impure_value* impure) |
| 2404 | { |
| 2405 | Request* request = tdbb->getRequest(); |
| 2406 | jrd_tra* transaction = request ? request->req_transaction : tdbb->getTransaction(); |
| 2407 | transaction = transaction->getOuter(); |
| 2408 | |
| 2409 | blb* blob = NULL; |
| 2410 | bid blob_id; |
| 2411 | dsc blobDsc; |
| 2412 | |
| 2413 | blob_id.clear(); |
| 2414 | blobDsc.clear(); |
| 2415 | |
| 2416 | const dsc* argDsc = EVL_expr(tdbb, request, args[0]); |
| 2417 | const bool arg0_null = (request->req_flags & req_null) || (argDsc == NULL); |
| 2418 | |
| 2419 | if (!arg0_null && argDsc->isBlob()) |
| 2420 | { |
| 2421 | blob_id = *reinterpret_cast<bid*>(argDsc->dsc_address); |
| 2422 | makeBlobAppendBlob(&blobDsc, argDsc, &blob_id); |
| 2423 | } |
| 2424 | |
| 2425 | // Try to get blob type from declared var\param |
| 2426 | if (!argDsc && (nodeIs<VariableNode>(args[0]) || |
| 2427 | nodeIs<ParameterNode>(args[0]) )) |
| 2428 | { |
| 2429 | argDsc = EVL_assign_to(tdbb, args[0]); |
| 2430 | if (argDsc && argDsc->isBlob()) |
| 2431 | makeBlobAppendBlob(&blobDsc, argDsc, &blob_id); |
| 2432 | } |
| 2433 | |
| 2434 | bool copyBlob = !blob_id.isEmpty(); |
| 2435 | if (copyBlob) |
| 2436 | { |
| 2437 | if (!blob_id.bid_internal.bid_relation_id) |
| 2438 | { |
| 2439 | if (!transaction->tra_blobs->locate(blob_id.bid_temp_id())) |
| 2440 | status_exception::raise(Arg::Gds(isc_bad_segstr_id)); |
| 2441 | |
| 2442 | BlobIndex blobIdx = transaction->tra_blobs->current(); |
| 2443 | if (!blobIdx.bli_materialized && (blobIdx.bli_blob_object->blb_flags & BLB_close_on_read)) |
| 2444 | { |
| 2445 | blob = blobIdx.bli_blob_object; |
| 2446 | copyBlob = false; |
| 2447 | } |
| 2448 | } |
| 2449 | } |
| 2450 | |
| 2451 | for (FB_SIZE_T i = 0; i < args.getCount(); i++) |
| 2452 | { |
| 2453 | if (i == 0) |
| 2454 | { |
| 2455 | if (arg0_null || argDsc->isBlob() && !copyBlob) |
| 2456 | continue; |
| 2457 | } |
| 2458 | else |
| 2459 | { |
nothing calls this directly
no test coverage detected