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

Function SDW_add

src/jrd/sdw.cpp:71–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69
70
71void SDW_add(thread_db* tdbb, const TEXT* file_name, USHORT shadow_number, USHORT file_flags)
72{
73/**************************************
74 *
75 * S D W _ a d d
76 *
77 **************************************
78 *
79 * Functional description
80 * Add a brand new shadowing file to the database.
81 *
82 **************************************/
83 SET_TDBB(tdbb);
84 Database* dbb = tdbb->getDatabase();
85
86 // Verify database file path against DatabaseAccess entry of firebird.conf
87 if (!JRD_verify_database_access(file_name))
88 {
89 ERR_post(Arg::Gds(isc_conf_access_denied) << Arg::Str("additional database file") <<
90 Arg::Str(file_name));
91 }
92
93 jrd_file* shadow_file = PIO_create(tdbb, file_name, false, false);
94
95 if (dbb->dbb_flags & (DBB_force_write | DBB_no_fs_cache))
96 {
97 PIO_force_write(shadow_file, dbb->dbb_flags & DBB_force_write,
98 dbb->dbb_flags & DBB_no_fs_cache);
99 }
100
101 SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_add");
102
103 Shadow* shadow = allocate_shadow(shadow_file, shadow_number, file_flags);
104
105 // dump out the header page, even if it is a conditional
106 // shadow--the page will be fixed up properly
107
108 if (shadow->sdw_flags & SDW_conditional)
109 shadow->sdw_flags &= ~SDW_conditional;
110 WIN window(HEADER_PAGE_NUMBER);
111 CCH_FETCH(tdbb, &window, LCK_write, pag_header);
112 CCH_MARK_MUST_WRITE(tdbb, &window);
113 CCH_write_all_shadows(tdbb, 0, window.win_bdb, window.win_bdb->bdb_buffer,
114 tdbb->tdbb_status_vector, false);
115 CCH_RELEASE(tdbb, &window);
116 if (file_flags & FILE_conditional)
117 shadow->sdw_flags |= SDW_conditional;
118}
119
120
121int SDW_add_file(thread_db* tdbb, const TEXT* file_name, SLONG start, USHORT shadow_number)

Callers

nothing calls this directly

Calls 13

SET_TDBBFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
PIO_createFunction · 0.85
allocate_shadowFunction · 0.85
CCH_FETCHFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
CCH_write_all_shadowsFunction · 0.85
CCH_RELEASEFunction · 0.85
getDatabaseMethod · 0.80
ERR_postFunction · 0.70

Tested by

no test coverage detected