| 375 | } |
| 376 | |
| 377 | FB_UINT64 initReplica() |
| 378 | { |
| 379 | if (m_connected) |
| 380 | return m_sequence; |
| 381 | |
| 382 | ClumpletWriter dpb(ClumpletReader::dpbList, MAX_DPB_SIZE); |
| 383 | |
| 384 | dpb.insertByte(isc_dpb_no_db_triggers, 1); |
| 385 | dpb.insertString(isc_dpb_user_name, DBA_USER_NAME); |
| 386 | dpb.insertString(isc_dpb_config, ParsedList::getNonLoopbackProviders(m_config->dbName)); |
| 387 | |
| 388 | #ifndef NO_DATABASE |
| 389 | DispatcherPtr provider; |
| 390 | FbLocalStatus localStatus; |
| 391 | |
| 392 | const auto att = |
| 393 | provider->attachDatabase(&localStatus, m_config->dbName.c_str(), |
| 394 | dpb.getBufferLength(), dpb.getBuffer()); |
| 395 | localStatus.check(); |
| 396 | m_attachment = att; |
| 397 | |
| 398 | const auto repl = m_attachment->createReplicator(&localStatus); |
| 399 | localStatus.check(); |
| 400 | m_replicator = repl; |
| 401 | |
| 402 | fb_assert(!m_sequence); |
| 403 | |
| 404 | RefPtr<ITransaction> transaction(REF_NO_INCR, |
| 405 | m_attachment->startTransaction(&localStatus, 0, NULL)); |
| 406 | localStatus.check(); |
| 407 | |
| 408 | const char* sql = |
| 409 | "select rdb$get_context('SYSTEM', 'REPLICATION_SEQUENCE') from rdb$database"; |
| 410 | |
| 411 | FB_MESSAGE(Result, CheckStatusWrapper, |
| 412 | (FB_BIGINT, sequence) |
| 413 | ) result(&localStatus, fb_get_master_interface()); |
| 414 | |
| 415 | m_attachment->execute(&localStatus, transaction, 0, sql, SQL_DIALECT_V6, |
| 416 | NULL, NULL, result.getMetadata(), result.getData()); |
| 417 | localStatus.check(); |
| 418 | |
| 419 | m_sequence = result->sequence; |
| 420 | #endif |
| 421 | m_connected = true; |
| 422 | |
| 423 | return m_sequence; |
| 424 | } |
| 425 | |
| 426 | void shutdown() |
| 427 | { |
no test coverage detected