Full processing of database name Returns true if alias was found in databases.conf
| 486 | // Full processing of database name |
| 487 | // Returns true if alias was found in databases.conf |
| 488 | bool expandDatabaseName(Firebird::PathName alias, |
| 489 | Firebird::PathName& file, |
| 490 | Firebird::RefPtr<const Config>* config) |
| 491 | { |
| 492 | try |
| 493 | { |
| 494 | aliasesConf().checkLoadConfig(); |
| 495 | } |
| 496 | catch (const fatal_exception& ex) |
| 497 | { |
| 498 | gds__log("File databases.conf contains bad data: %s", ex.what()); |
| 499 | Arg::Gds(isc_server_misconfigured).raise(); |
| 500 | } |
| 501 | |
| 502 | // remove whitespaces from database name |
| 503 | alias.trim(); |
| 504 | |
| 505 | ReadLockGuard guard(aliasesConf().rwLock, "expandDatabaseName"); |
| 506 | |
| 507 | // First of all check in databases.conf |
| 508 | if (resolveAlias(alias, file, config)) |
| 509 | { |
| 510 | return true; |
| 511 | } |
| 512 | |
| 513 | // Now try ISC_PATH environment variable |
| 514 | if (!setPath(alias, file)) |
| 515 | { |
| 516 | // At this step check DatabaseAccess paths in firebird.conf |
| 517 | if (!resolveDatabaseAccess(alias, file)) |
| 518 | { |
| 519 | // Last chance - regular filename expansion |
| 520 | file = alias; |
| 521 | |
| 522 | ISC_systemToUtf8(file); |
| 523 | ISC_unescape(file); |
| 524 | ISC_utf8ToSystem(file); |
| 525 | |
| 526 | ISC_expand_filename(file, true); |
| 527 | |
| 528 | ISC_systemToUtf8(file); |
| 529 | ISC_escape(file); |
| 530 | ISC_utf8ToSystem(file); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | // Search for correct config in databases.conf |
| 535 | if (config) |
| 536 | { |
| 537 | DbName* db = aliasesConf().dbHash.lookup(file); |
| 538 | #ifdef HAVE_ID_BY_NAME |
| 539 | if (!db) |
| 540 | { |
| 541 | UCharBuffer id; |
| 542 | os_utils::getUniqueFileId(file.c_str(), id); |
| 543 | if (id.hasData()) |
| 544 | { |
| 545 | Id* i = aliasesConf().idHash.lookup(id); |
no test coverage detected