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

Method doUpdate

src/jrd/replication/Applier.cpp:1301–1399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1299}
1300
1301void Applier::doUpdate(thread_db* tdbb, record_param* orgRpb, record_param* newRpb,
1302 jrd_tra* transaction, BlobList* blobs)
1303{
1304 fb_assert(!(transaction->tra_flags & TRA_system));
1305
1306 const auto orgRecord = orgRpb->rpb_record;
1307 const auto newRecord = newRpb->rpb_record;
1308 const auto format = newRecord->getFormat();
1309 const auto relation = newRpb->rpb_relation;
1310
1311 RLCK_reserve_relation(tdbb, transaction, relation, true);
1312
1313 for (USHORT id = 0; id < format->fmt_count; id++)
1314 {
1315 dsc desc;
1316 if (DTYPE_IS_BLOB(format->fmt_desc[id].dsc_dtype) &&
1317 EVL_field(NULL, newRecord, id, &desc))
1318 {
1319 const auto dstBlobId = (bid*) desc.dsc_address;
1320 const auto srcBlobId = (blobs && id < blobs->getCount()) ? (bid*) &(*blobs)[id] : NULL;
1321
1322 if (!dstBlobId->isEmpty())
1323 {
1324 const bool same_blobs = (srcBlobId && *srcBlobId == *dstBlobId);
1325
1326 if (same_blobs)
1327 {
1328 if (EVL_field(NULL, orgRecord, id, &desc))
1329 *dstBlobId = *(bid*) desc.dsc_address;
1330 else
1331 dstBlobId->clear();
1332 }
1333 else
1334 {
1335 ULONG tempBlobId;
1336 bool found = false;
1337
1338 const auto numericId = dstBlobId->get_permanent_number().getValue();
1339
1340 if (transaction->tra_repl_blobs.get(numericId, tempBlobId) &&
1341 transaction->tra_blobs->locate(tempBlobId))
1342 {
1343 const auto current = &transaction->tra_blobs->current();
1344
1345 if (!current->bli_materialized)
1346 {
1347 const auto blob = current->bli_blob_object;
1348 fb_assert(blob);
1349 blob->blb_relation = relation;
1350 blob->blb_sub_type = desc.getBlobSubType();
1351 blob->blb_charset = desc.getCharSet();
1352 dstBlobId->set_permanent(relation->rel_id, DPM_store_blob(tdbb, blob, newRecord));
1353 current->bli_materialized = true;
1354 current->bli_blob_id = *dstBlobId;
1355 transaction->tra_blobs->fastRemove();
1356 found = true;
1357 }
1358 }

Callers

nothing calls this directly

Calls 15

RLCK_reserve_relationFunction · 0.85
DTYPE_IS_BLOBFunction · 0.85
EVL_fieldFunction · 0.85
VIO_modifyFunction · 0.85
IDX_modifyFunction · 0.85
REPL_modifyFunction · 0.85
get_permanent_numberMethod · 0.80
getBlobSubTypeMethod · 0.80
set_permanentMethod · 0.80
BLB_cancelMethod · 0.80
setTransactionNumberMethod · 0.80
raiseErrorFunction · 0.70

Tested by

no test coverage detected