MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / initAttachment

Function initAttachment

src/jrd/jrd.cpp:7346–7534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7344
7345
7346static JAttachment* initAttachment(thread_db* tdbb, const PathName& expanded_name,
7347 const PathName& alias_name, RefPtr<const Config> config, bool attach_flag,
7348 const DatabaseOptions& options, RefMutexUnlock& initGuard, IPluginConfig* pConf,
7349 JProvider* provider)
7350{
7351/**************************************
7352 *
7353 * i n i t A t t a c h m e n t
7354 *
7355 **************************************
7356 *
7357 * Functional description
7358 * Initialize for database access. First call from both CREATE and ATTACH.
7359 * Upon entry mutex dbInitMutex must be locked.
7360 *
7361 **************************************/
7362 SET_TDBB(tdbb);
7363 fb_assert(dbInitMutex->locked());
7364
7365 // make sure that no new attachments arrive after shutdown started
7366 if (engineShutdown)
7367 {
7368 Arg::Gds(isc_att_shutdown).raise();
7369 }
7370
7371 // Initialize standard random generator.
7372 // MSVC (at least since version 7) have per-thread random seed.
7373 // As we don't know who uses per-thread seed, this should work for both cases.
7374 static bool first_rand = true;
7375 static int first_rand_value = rand();
7376
7377 if (first_rand || (rand() == first_rand_value))
7378 srand(time(NULL));
7379
7380 first_rand = false;
7381
7382#ifdef HAVE_ID_BY_NAME
7383 UCharBuffer db_id;
7384 os_utils::getUniqueFileId(expanded_name.c_str(), db_id);
7385#endif
7386
7387 engineStartup.init();
7388
7389 if (!attach_flag && options.dpb_set_db_charset.hasData() &&
7390 !IntlManager::charSetInstalled(options.dpb_set_db_charset))
7391 {
7392 ERR_post(Arg::Gds(isc_charset_not_installed) << options.dpb_set_db_charset);
7393 }
7394
7395 // Check to see if the database is already attached
7396 Database* dbb = NULL;
7397 JAttachment* jAtt;
7398
7399 bool shared = false;
7400
7401 { // scope
7402 MutexLockGuard listGuard(databases_mutex, FB_FUNCTION);
7403

Callers 2

internalAttachMethod · 0.85
createDatabaseMethod · 0.85

Calls 15

SET_TDBBFunction · 0.85
GdsClass · 0.85
raiseFunction · 0.85
create_attachmentFunction · 0.85
ERR_post_warningFunction · 0.85
WarningClass · 0.85
StrClass · 0.85
createFunction · 0.85
ExtEngineManagerClass · 0.85
getServerModeMethod · 0.80
linkWithMethod · 0.80
doesExistMethod · 0.80

Tested by

no test coverage detected