From 8f16fe232690284645bfe6018465844dccc779cf Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Thu, 17 Jul 2025 15:58:47 +0300 Subject: [PATCH] Move blob searching in Replicator to new method --- src/jrd/replication/Replicator.cpp | 51 ++++++++++++------------------ src/jrd/replication/Replicator.h | 2 ++ 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/jrd/replication/Replicator.cpp b/src/jrd/replication/Replicator.cpp index 470a43962df..447a75eba33 100644 --- a/src/jrd/replication/Replicator.cpp +++ b/src/jrd/replication/Replicator.cpp @@ -306,21 +306,7 @@ void Replicator::insertRecord(CheckStatusWrapper* status, { try { - for (unsigned id = 0; id < record->getCount(); id++) - { - IReplicatedField* field = record->getField(id); - if (field != nullptr) - { - auto type = field->getType(); - if (type == SQL_ARRAY || type == SQL_BLOB) - { - const auto blobId = (ISC_QUAD*) field->getData(); - - if (blobId && !BlobWrapper::blobIsNull(*blobId)) - storeBlob(transaction, *blobId); - } - } - } + storeBlobs(transaction, record); const auto length = record->getRawLength(); const auto data = record->getRawData(); @@ -353,21 +339,7 @@ void Replicator::updateRecord(CheckStatusWrapper* status, { try { - for (unsigned id = 0; id < newRecord->getCount(); id++) - { - IReplicatedField* field = newRecord->getField(id); - if (field != nullptr) - { - auto type = field->getType(); - if (type == SQL_ARRAY || type == SQL_BLOB) - { - const auto blobId = (ISC_QUAD*) field->getData(); - - if (blobId && !BlobWrapper::blobIsNull(*blobId)) - storeBlob(transaction, *blobId); - } - } - } + storeBlobs(transaction, newRecord); const auto orgLength = orgRecord->getRawLength(); const auto orgData = orgRecord->getRawData(); @@ -454,6 +426,25 @@ void Replicator::executeSqlIntl(CheckStatusWrapper* status, } } +void Replicator::storeBlobs(Transaction* transaction, Firebird::IReplicatedRecord* record) +{ + for (unsigned id = 0; id < record->getCount(); id++) + { + IReplicatedField* field = record->getField(id); + if (field == nullptr) + continue; + + auto type = field->getType(); + if (type == SQL_ARRAY || type == SQL_BLOB) + { + const auto blobId = (ISC_QUAD*) field->getData(); + + if (blobId && !BlobWrapper::blobIsNull(*blobId)) + storeBlob(transaction, *blobId); + } + } +} + void Replicator::cleanupTransaction(CheckStatusWrapper* status, SINT64 number) { diff --git a/src/jrd/replication/Replicator.h b/src/jrd/replication/Replicator.h index c24f870f2bb..c166fc9da9f 100644 --- a/src/jrd/replication/Replicator.h +++ b/src/jrd/replication/Replicator.h @@ -341,6 +341,8 @@ namespace Replication unsigned charset, const char* schemaSearchPath, const char* sql); + + void storeBlobs(Transaction* transaction, Firebird::IReplicatedRecord* record); }; } // namespace