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

Method updateRecord

src/jrd/replication/Applier.cpp:700–840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

698}
699
700void Applier::updateRecord(thread_db* tdbb, TraNumber traNum,
701 const MetaName& relName,
702 ULONG orgLength, const UCHAR* orgData,
703 ULONG newLength, const UCHAR* newData)
704{
705 jrd_tra* transaction = NULL;
706 if (!m_txnMap.get(traNum, transaction))
707 raiseError("Transaction %" SQUADFORMAT" is not found", traNum);
708
709 LocalThreadContext context(tdbb, transaction, m_request);
710 Jrd::ContextPoolHolder context2(tdbb, m_request->req_pool);
711
712 TRA_attach_request(transaction, m_request);
713
714 const auto relation = MET_lookup_relation(tdbb, relName);
715 if (!relation)
716 raiseError("Table %s is not found", relName.c_str());
717
718 if (!(relation->rel_flags & REL_scanned))
719 MET_scan_relation(tdbb, relation);
720
721 const auto orgFormat = findFormat(tdbb, relation, orgLength);
722
723 record_param orgRpb;
724 orgRpb.rpb_relation = relation;
725
726 orgRpb.rpb_record = m_record;
727 const auto orgRecord = m_record =
728 VIO_record(tdbb, &orgRpb, orgFormat, tdbb->getDefaultPool());
729
730 orgRpb.rpb_format_number = orgFormat->fmt_version;
731 orgRpb.rpb_address = orgRecord->getData();
732 orgRpb.rpb_length = orgLength;
733 orgRecord->copyDataFrom(orgData);
734
735 BlobList sourceBlobs(getPool());
736 sourceBlobs.resize(orgFormat->fmt_count);
737 for (USHORT id = 0; id < orgFormat->fmt_count; id++)
738 {
739 dsc desc;
740 if (DTYPE_IS_BLOB(orgFormat->fmt_desc[id].dsc_dtype) &&
741 EVL_field(NULL, orgRecord, id, &desc))
742 {
743 const auto source = (bid*) desc.dsc_address;
744
745 if (!source->isEmpty())
746 sourceBlobs[id] = *source;
747 }
748 }
749
750 index_desc idx;
751 const auto indexed = lookupRecord(tdbb, relation, orgRecord, idx);
752
753 bool found = false;
754 AutoPtr<Record> cleanup;
755
756 if (m_bitmap && m_bitmap->getFirst())
757 {

Callers 1

REPL_modifyFunction · 0.45

Calls 15

TRA_attach_requestFunction · 0.85
VIO_recordFunction · 0.85
DTYPE_IS_BLOBFunction · 0.85
EVL_fieldFunction · 0.85
VIO_getFunction · 0.85
MOV_compareFunction · 0.85
MOV_moveFunction · 0.85
copyDataFromMethod · 0.80
raiseErrorFunction · 0.70
getMethod · 0.45
c_strMethod · 0.45
getDefaultPoolMethod · 0.45

Tested by

no test coverage detected