// Probably file arrived on the disk bool notifyDatabaseName(const Firebird::PathName& file) { #ifdef HAVE_ID_BY_NAME // notifyDatabaseName typically causes changes in aliasesConf() // cause it's called only from Config created for missing database. // Therefore always take write lock at once. WriteLockGuard guard(aliasesConf().rwLock, "notifyDatabaseName"); DbName* db = aliasesConf().dbHash.lookup(file); if (!db) return true; if (db->id) return true; UCharBuffer id; os_utils::getUniqueFileId(file.c_str(), id); if (id.hasData()) { aliasesConf().linkId(db, id); return true; } #endif return false; }
// Full processing of database name // Returns true if alias was found in databases.conf bool expandDatabaseName(Firebird::PathName alias, Firebird::PathName& file, Firebird::RefPtr<Config>* config) { try { aliasesConf().checkLoadConfig(); } catch (const fatal_exception& ex) { gds__log("File databases.conf contains bad data: %s", ex.what()); Arg::Gds(isc_server_misconfigured).raise(); } // remove whitespaces from database name alias.trim(); ReadLockGuard guard(aliasesConf().rwLock, "expandDatabaseName"); // First of all check in databases.conf if (resolveAlias(alias, file, config)) { return true; } // Now try ISC_PATH environment variable if (!setPath(alias, file)) { // At this step check DatabaseAccess paths in firebird.conf if (!resolveDatabaseAccess(alias, file)) { // Last chance - regular filename expansion file = alias; ISC_systemToUtf8(file); ISC_unescape(file); ISC_utf8ToSystem(file); ISC_expand_filename(file, true); ISC_systemToUtf8(file); ISC_escape(file); ISC_utf8ToSystem(file); } } // Search for correct config in databases.conf if (config) { DbName* db = aliasesConf().dbHash.lookup(file); #ifdef HAVE_ID_BY_NAME if (!db) { UCharBuffer id; os_utils::getUniqueFileId(file.c_str(), id); if (id.hasData()) { Id* i = aliasesConf().idHash.lookup(id); if (i) db = i->db; } } #endif *config = (db && db->config.hasData()) ? db->config : Config::getDefaultConfig(); } return false; }