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

Method attachOrCreateDatabase

src/yvalve/why.cpp:6498–6635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6496}
6497
6498YAttachment* Dispatcher::attachOrCreateDatabase(CheckStatusWrapper* status, bool createFlag,
6499 const char* filename, unsigned int dpbLength, const unsigned char* dpb)
6500{
6501 try
6502 {
6503 DispatcherEntry entry(status);
6504
6505 if (!filename)
6506 status_exception::raise(Arg::Gds(isc_bad_db_format) << Arg::Str(""));
6507
6508 if (dpbLength > 0 && !dpb)
6509 status_exception::raise(Arg::Gds(isc_bad_dpb_form));
6510
6511 ClumpletWriter newDpb(ClumpletReader::dpbList, MAX_DPB_SIZE, dpb, dpbLength);
6512 bool utfData = newDpb.find(isc_dpb_utf8_filename);
6513
6514 // Take care about DPB
6515 setLogin(newDpb, false);
6516
6517 if (!newDpb.find(isc_dpb_session_time_zone))
6518 {
6519 const char* defaultTimeZone = Config::getDefaultTimeZone();
6520
6521 if (defaultTimeZone && defaultTimeZone[0])
6522 newDpb.insertString(isc_dpb_session_time_zone, defaultTimeZone);
6523 }
6524
6525 if (!utfData)
6526 IntlDpb().toUtf8(newDpb);
6527
6528 // Take care about filename
6529 PathName orgFilename(filename);
6530 if (utfData)
6531 {
6532 ISC_utf8ToSystem(orgFilename);
6533 }
6534 orgFilename.rtrim();
6535
6536 PathName expandedFilename;
6537 RefPtr<const Config> config;
6538 if (expandDatabaseName(orgFilename, expandedFilename, &config))
6539 {
6540 expandedFilename = orgFilename;
6541 }
6542
6543 if (newDpb.find(isc_dpb_config))
6544 {
6545 string dpb_config;
6546 newDpb.getString(dpb_config);
6547 Config::merge(config, &dpb_config);
6548 }
6549
6550 // Convert to UTF8
6551 ISC_systemToUtf8(orgFilename);
6552 ISC_systemToUtf8(expandedFilename);
6553
6554 // Add original filename to DPB
6555 if (orgFilename != expandedFilename && !newDpb.find(isc_dpb_org_filename))

Callers

nothing calls this directly

Calls 15

raiseFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
setLoginFunction · 0.85
IntlDpbClass · 0.85
ISC_utf8ToSystemFunction · 0.85
expandDatabaseNameFunction · 0.85
ISC_systemToUtf8Function · 0.85
rtrimMethod · 0.80
pluginMethod · 0.80
YAttachmentClass · 0.70
mergeFunction · 0.50

Tested by

no test coverage detected