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

Function PAG_add_file

src/jrd/pag.cpp:223–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221
222
223USHORT PAG_add_file(thread_db* tdbb, const TEXT* file_name, SLONG start)
224{
225/**************************************
226 *
227 * P A G _ a d d _ f i l e
228 *
229 **************************************
230 *
231 * Functional description
232 * Add a file to the current database. Return the sequence number for the new file.
233 *
234 **************************************/
235 SET_TDBB(tdbb);
236 Database* dbb = tdbb->getDatabase();
237 CHECK_DBB(dbb);
238
239 err_post_if_database_is_readonly(dbb);
240
241 // Find current last file
242
243 PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
244 jrd_file* file = pageSpace->file;
245 while (file->fil_next) {
246 file = file->fil_next;
247 }
248
249 // Verify database file path against DatabaseAccess entry of firebird.conf
250 if (!JRD_verify_database_access(file_name))
251 {
252 string fileName(file_name);
253 ISC_systemToUtf8(fileName);
254 ERR_post(Arg::Gds(isc_conf_access_denied) << Arg::Str("additional database file") <<
255 Arg::Str(fileName));
256 }
257
258 // Create the file. If the sequence number comes back zero, it didn't work, so punt
259
260 const USHORT sequence = PIO_add_file(tdbb, pageSpace->file, file_name, start);
261 if (!sequence)
262 return 0;
263
264 // Create header page for new file
265
266 jrd_file* next = file->fil_next;
267
268 if (dbb->dbb_flags & (DBB_force_write | DBB_no_fs_cache))
269 {
270 PIO_force_write(next, dbb->dbb_flags & DBB_force_write, dbb->dbb_flags & DBB_no_fs_cache);
271 }
272
273 WIN window(DB_PAGE_SPACE, next->fil_min_page);
274 header_page* header = (header_page*) CCH_fake(tdbb, &window, 1);
275 header->hdr_header.pag_type = pag_header;
276 header->hdr_sequence = sequence;
277 header->hdr_page_size = dbb->dbb_page_size;
278 header->hdr_data[0] = HDR_end;
279 header->hdr_end = HDR_SIZE;
280 next->fil_sequence = sequence;

Callers

nothing calls this directly

Calls 15

SET_TDBBFunction · 0.85
CHECK_DBBFunction · 0.85
ISC_systemToUtf8Function · 0.85
GdsClass · 0.85
StrClass · 0.85
CCH_fakeFunction · 0.85
CCH_RELEASEFunction · 0.85
CCH_FETCHFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
CCH_MARKFunction · 0.85

Tested by

no test coverage detected