| 358 | |
| 359 | |
| 360 | ULONG MOV_make_string2(Jrd::thread_db* tdbb, |
| 361 | const dsc* desc, |
| 362 | USHORT ttype, |
| 363 | UCHAR** address, |
| 364 | Jrd::MoveBuffer& buffer, |
| 365 | bool limit) |
| 366 | { |
| 367 | /************************************** |
| 368 | * |
| 369 | * M O V _ m a k e _ s t r i n g 2 |
| 370 | * |
| 371 | ************************************** |
| 372 | * |
| 373 | * Functional description |
| 374 | * Make a string, in a specified text type, out of a descriptor. |
| 375 | * The address of the resultant string is returned by reference. |
| 376 | * MOV_make_string2 returns the length of the string in bytes. |
| 377 | * |
| 378 | **************************************/ |
| 379 | |
| 380 | if (desc->isBlob()) |
| 381 | { |
| 382 | // fake descriptor |
| 383 | dsc temp; |
| 384 | temp.dsc_dtype = dtype_text; |
| 385 | temp.setTextType(ttype); |
| 386 | |
| 387 | Firebird::UCharBuffer bpb; |
| 388 | BLB_gen_bpb_from_descs(desc, &temp, bpb); |
| 389 | |
| 390 | Jrd::blb* blob = Jrd::blb::open2(tdbb, tdbb->getRequest()->req_transaction, |
| 391 | reinterpret_cast<Jrd::bid*>(desc->dsc_address), bpb.getCount(), bpb.begin()); |
| 392 | |
| 393 | ULONG size; |
| 394 | |
| 395 | if (temp.getCharSet() == desc->getCharSet()) |
| 396 | { |
| 397 | size = blob->blb_length; |
| 398 | } |
| 399 | else |
| 400 | { |
| 401 | size = (blob->blb_length / INTL_charset_lookup(tdbb, desc->getCharSet())->minBytesPerChar()) * |
| 402 | INTL_charset_lookup(tdbb, temp.getCharSet())->maxBytesPerChar(); |
| 403 | } |
| 404 | |
| 405 | *address = buffer.getBuffer(size); |
| 406 | |
| 407 | size = blob->BLB_get_data(tdbb, *address, size, true); |
| 408 | |
| 409 | if (limit && size > MAX_COLUMN_SIZE) |
| 410 | { |
| 411 | ERR_post(Arg::Gds(isc_arith_except) << |
| 412 | Arg::Gds(isc_blob_truncation)); |
| 413 | } |
| 414 | |
| 415 | return size; |
| 416 | } |
| 417 |
no test coverage detected