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

Function move_from_string

src/jrd/blb.cpp:2567–2680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2565
2566
2567static void move_from_string(thread_db* tdbb, const dsc* from_desc, dsc* to_desc,
2568 jrd_rel* relation, Record* record, USHORT fieldId)
2569{
2570/**************************************
2571 *
2572 * m o v e _ f r o m _ s t r i n g
2573 *
2574 **************************************
2575 *
2576 * Functional description
2577 * Perform an assignment to a blob field. It's capable of handling
2578 * strings (and anything that could be converted to strings) by
2579 * doing an internal conversion to blob and then calling blb::move
2580 * with that new blob.
2581 *
2582 **************************************/
2583 SET_TDBB (tdbb);
2584
2585 const UCHAR charSet = INTL_GET_CHARSET(from_desc);
2586 UCHAR* fromstr = NULL;
2587
2588 MoveBuffer buffer;
2589 const int length = MOV_make_string2(tdbb, from_desc, charSet, &fromstr, buffer);
2590 const UCHAR toCharSet = to_desc->getCharSet();
2591
2592 if ((charSet == CS_NONE || charSet == CS_BINARY || charSet == toCharSet) &&
2593 toCharSet != CS_NONE && toCharSet != CS_BINARY)
2594 {
2595 if (!INTL_charset_lookup(tdbb, toCharSet)->wellFormed(length, fromstr))
2596 status_exception::raise(Arg::Gds(isc_malformed_string));
2597 }
2598
2599 Request* request = tdbb->getRequest();
2600 jrd_tra* transaction = request ? request->req_transaction : tdbb->getTransaction();
2601 transaction = transaction->getOuter();
2602
2603 UCharBuffer bpb;
2604
2605 if (!(from_desc->isText() && from_desc->getCharSet() == CS_BINARY))
2606 BLB_gen_bpb_from_descs(from_desc, to_desc, bpb);
2607
2608 bid temp_bid;
2609 temp_bid.clear();
2610 blb* blob = blb::create2(tdbb, transaction, &temp_bid, bpb.getCount(), bpb.begin());
2611
2612 DSC blob_desc;
2613 blob_desc.clear();
2614
2615 blob_desc.dsc_scale = to_desc->dsc_scale; // blob charset
2616 blob_desc.dsc_flags = (blob_desc.dsc_flags & 0xFF) | (to_desc->dsc_flags & 0xFF00); // blob collation
2617 blob_desc.dsc_sub_type = to_desc->dsc_sub_type;
2618 blob_desc.dsc_dtype = dtype_blob;
2619 blob_desc.dsc_length = sizeof(ISC_QUAD);
2620 blob_desc.dsc_address = reinterpret_cast<UCHAR*>(&temp_bid);
2621 blob->BLB_put_segment(tdbb, fromstr, length);
2622 blob->BLB_close(tdbb);
2623 ULONG blob_temp_id = blob->getTempId();
2624 blb::move(tdbb, &blob_desc, to_desc, relation, record, fieldId);

Callers 1

moveMethod · 0.85

Calls 15

SET_TDBBFunction · 0.85
MOV_make_string2Function · 0.85
INTL_charset_lookupFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
BLB_gen_bpb_from_descsFunction · 0.85
wellFormedMethod · 0.80
getOuterMethod · 0.80
isTextMethod · 0.80
BLB_put_segmentMethod · 0.80
BLB_closeMethod · 0.80
getTempIdMethod · 0.80

Tested by

no test coverage detected