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

Method attach

src/jrd/extds/IscDS.cpp:107–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void IscConnection::attach(thread_db* tdbb)
108{
109 Attachment* attachment = tdbb->getAttachment();
110
111 // Avoid change of m_dpb by validatePassword() below
112 ClumpletWriter newDpb(ClumpletReader::dpbList, MAX_DPB_SIZE, m_dpb.begin(), m_dpb.getCount());
113 if (validatePassword(tdbb, m_dbName, newDpb))
114 {
115 // After successful password validation only local for current server providers
116 // should be used. Currently we do not distinguish provider's properties
117 // therefore use working but definitely not ideal way to avoid remote & loopback
118 // providers to be used - add empty isc_dpb_address_path clumplet to DPB.
119 // See also get_new_dpb() in interface.cpp.
120
121 ClumpletWriter address_record(ClumpletReader::UnTagged, MAX_UCHAR - 2);
122 ClumpletWriter address_stack_buffer(ClumpletReader::UnTagged, MAX_UCHAR - 2);
123 address_stack_buffer.insertBytes(isc_dpb_address,
124 address_record.getBuffer(), address_record.getBufferLength());
125
126 newDpb.insertBytes(isc_dpb_address_path, address_stack_buffer.getBuffer(),
127 address_stack_buffer.getBufferLength());
128 }
129 newDpb.insertInt(isc_dpb_ext_call_depth, attachment->att_ext_call_depth + 1);
130
131 if (newDpb.getBufferLength() > MAX_USHORT)
132 {
133 ERR_post(Arg::Gds(isc_imp_exc) <<
134 Arg::Gds(isc_random) << Arg::Str("DPB size greater than 64KB"));
135 }
136
137 FbLocalStatus status;
138 {
139 EngineCallbackGuard guard(tdbb, *this, FB_FUNCTION);
140
141 ICryptKeyCallback* cb = &m_cryptCallbackRedir;
142 try
143 {
144 m_iscProvider.fb_database_crypt_callback(&status, cb);
145 if (status->getState() & IStatus::STATE_ERRORS) {
146 raise(&status, tdbb, "crypt_callback");
147 }
148
149 m_iscProvider.isc_attach_database(&status, m_dbName.length(), m_dbName.c_str(),
150 &m_handle, newDpb.getBufferLength(),
151 reinterpret_cast<const char*>(newDpb.getBuffer()));
152 if (status->getState() & IStatus::STATE_ERRORS) {
153 raise(&status, tdbb, "attach");
154 }
155 }
156 catch (const Exception&)
157 {
158 m_iscProvider.fb_database_crypt_callback(&status, NULL);
159 throw;
160 }
161
162 m_iscProvider.fb_database_crypt_callback(&status, NULL);
163 if (status->getState() & IStatus::STATE_ERRORS) {
164 raise(&status, tdbb, "crypt_callback");

Callers 1

createConnectionMethod · 0.45

Calls 15

validatePasswordFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
raiseFunction · 0.85
isc_attach_databaseMethod · 0.80
isc_database_infoMethod · 0.80
getClumpTagMethod · 0.80
getClumpLengthMethod · 0.80
isc_vax_integerMethod · 0.80
ERR_postFunction · 0.50
getAttachmentMethod · 0.45

Tested by

no test coverage detected