Skip to content

Commit 8f16fe2

Browse files
author
Artyom Abakumov
committed
Move blob searching in Replicator to new method
1 parent 581f0ea commit 8f16fe2

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

src/jrd/replication/Replicator.cpp

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,7 @@ void Replicator::insertRecord(CheckStatusWrapper* status,
306306
{
307307
try
308308
{
309-
for (unsigned id = 0; id < record->getCount(); id++)
310-
{
311-
IReplicatedField* field = record->getField(id);
312-
if (field != nullptr)
313-
{
314-
auto type = field->getType();
315-
if (type == SQL_ARRAY || type == SQL_BLOB)
316-
{
317-
const auto blobId = (ISC_QUAD*) field->getData();
318-
319-
if (blobId && !BlobWrapper::blobIsNull(*blobId))
320-
storeBlob(transaction, *blobId);
321-
}
322-
}
323-
}
309+
storeBlobs(transaction, record);
324310

325311
const auto length = record->getRawLength();
326312
const auto data = record->getRawData();
@@ -353,21 +339,7 @@ void Replicator::updateRecord(CheckStatusWrapper* status,
353339
{
354340
try
355341
{
356-
for (unsigned id = 0; id < newRecord->getCount(); id++)
357-
{
358-
IReplicatedField* field = newRecord->getField(id);
359-
if (field != nullptr)
360-
{
361-
auto type = field->getType();
362-
if (type == SQL_ARRAY || type == SQL_BLOB)
363-
{
364-
const auto blobId = (ISC_QUAD*) field->getData();
365-
366-
if (blobId && !BlobWrapper::blobIsNull(*blobId))
367-
storeBlob(transaction, *blobId);
368-
}
369-
}
370-
}
342+
storeBlobs(transaction, newRecord);
371343

372344
const auto orgLength = orgRecord->getRawLength();
373345
const auto orgData = orgRecord->getRawData();
@@ -454,6 +426,25 @@ void Replicator::executeSqlIntl(CheckStatusWrapper* status,
454426
}
455427
}
456428

429+
void Replicator::storeBlobs(Transaction* transaction, Firebird::IReplicatedRecord* record)
430+
{
431+
for (unsigned id = 0; id < record->getCount(); id++)
432+
{
433+
IReplicatedField* field = record->getField(id);
434+
if (field == nullptr)
435+
continue;
436+
437+
auto type = field->getType();
438+
if (type == SQL_ARRAY || type == SQL_BLOB)
439+
{
440+
const auto blobId = (ISC_QUAD*) field->getData();
441+
442+
if (blobId && !BlobWrapper::blobIsNull(*blobId))
443+
storeBlob(transaction, *blobId);
444+
}
445+
}
446+
}
447+
457448
void Replicator::cleanupTransaction(CheckStatusWrapper* status,
458449
SINT64 number)
459450
{

src/jrd/replication/Replicator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ namespace Replication
341341
unsigned charset,
342342
const char* schemaSearchPath,
343343
const char* sql);
344+
345+
void storeBlobs(Transaction* transaction, Firebird::IReplicatedRecord* record);
344346
};
345347

346348
} // namespace

0 commit comments

Comments
 (0)