8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 19:23:03 +01:00

Better scope for RAII holder and error handling.

This commit is contained in:
Dmitry Yemanov 2023-01-13 12:21:02 +03:00
parent 75f3c367e8
commit 923b7e12ed

View File

@ -236,16 +236,30 @@ Applier* Applier::create(thread_db* tdbb)
if (!attachment->locksmith(tdbb, REPLICATE_INTO_DATABASE))
status_exception::raise(Arg::Gds(isc_miss_prvlg) << "REPLICATE_INTO_DATABASE");
jrd_req* request = nullptr;
const auto req_pool = attachment->createPool();
try
{
Jrd::ContextPoolHolder context(tdbb, req_pool);
AutoPtr<CompilerScratch> csb(FB_NEW_POOL(*req_pool) CompilerScratch(*req_pool));
const auto request = JrdStatement::makeRequest(tdbb, csb, true);
request = JrdStatement::makeRequest(tdbb, csb, true);
request->validateTimeStamp();
request->req_attachment = attachment;
}
catch (const Exception&)
{
if (request)
CMP_release(tdbb, request);
else
attachment->deletePool(req_pool);
auto& att_pool = *attachment->att_pool;
const auto applier = FB_NEW_POOL(att_pool) Applier(att_pool, dbb->dbb_filename, request);
throw;
}
const auto applier = FB_NEW_POOL(*attachment->att_pool)
Applier(*attachment->att_pool, dbb->dbb_filename, request);
attachment->att_repl_appliers.add(applier);
return applier;