| 226 | |
| 227 | |
| 228 | Applier* Applier::create(thread_db* tdbb) |
| 229 | { |
| 230 | const auto dbb = tdbb->getDatabase(); |
| 231 | |
| 232 | if (!dbb->isReplica()) |
| 233 | raiseError("Database is not in the replica mode"); |
| 234 | |
| 235 | const auto attachment = tdbb->getAttachment(); |
| 236 | |
| 237 | if (!attachment->locksmith(tdbb, REPLICATE_INTO_DATABASE)) |
| 238 | status_exception::raise(Arg::Gds(isc_miss_prvlg) << "REPLICATE_INTO_DATABASE"); |
| 239 | |
| 240 | Request* request = nullptr; |
| 241 | const auto req_pool = attachment->createPool(); |
| 242 | |
| 243 | try |
| 244 | { |
| 245 | Jrd::ContextPoolHolder context(tdbb, req_pool); |
| 246 | AutoPtr<CompilerScratch> csb(FB_NEW_POOL(*req_pool) CompilerScratch(*req_pool)); |
| 247 | |
| 248 | request = Statement::makeRequest(tdbb, csb, true); |
| 249 | request->validateTimeStamp(); |
| 250 | request->req_attachment = attachment; |
| 251 | } |
| 252 | catch (const Exception&) |
| 253 | { |
| 254 | if (request) |
| 255 | CMP_release(tdbb, request); |
| 256 | else |
| 257 | attachment->deletePool(req_pool); |
| 258 | |
| 259 | throw; |
| 260 | } |
| 261 | |
| 262 | const auto config = dbb->replConfig(); |
| 263 | const bool cascade = (config && config->cascadeReplication); |
| 264 | |
| 265 | const auto applier = FB_NEW_POOL(*attachment->att_pool) |
| 266 | Applier(*attachment->att_pool, dbb->dbb_filename, request, cascade); |
| 267 | |
| 268 | attachment->att_repl_appliers.add(applier); |
| 269 | |
| 270 | return applier; |
| 271 | } |
| 272 | |
| 273 | void Applier::shutdown(thread_db* tdbb) |
| 274 | { |
nothing calls this directly
no test coverage detected