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

Function SDW_start

src/jrd/sdw.cpp:921–1095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919
920
921void SDW_start(thread_db* tdbb, const TEXT* file_name,
922 USHORT shadow_number, USHORT file_flags, bool delete_files)
923{
924/**************************************
925 *
926 * S D W _ s t a r t
927 *
928 **************************************
929 *
930 * Functional description
931 * Commence shadowing on a previously created shadow file.
932 *
933 * <delete_files> is true if we are not actually starting shadowing,
934 * but deleting inaccessible shadow files.
935 *
936 **************************************/
937 SET_TDBB(tdbb);
938 Database* dbb = tdbb->getDatabase();
939
940 SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_start");
941
942 USHORT header_fetched = 0;
943
944 // check that this shadow has not already been started,
945 // (unless it is marked as invalid, in which case it may
946 // be an old shadow of the same number)
947
948 Shadow* shadow;
949 for (shadow = dbb->dbb_shadow; shadow; shadow = shadow->sdw_next)
950 {
951 if ((shadow->sdw_number == shadow_number) && !(shadow->sdw_flags & SDW_INVALID))
952 {
953 return;
954 }
955 }
956
957 for (shadow = dbb->dbb_shadow; shadow; shadow = shadow->sdw_next)
958 {
959 if (shadow->sdw_number == shadow_number)
960 break;
961 }
962
963 // check to see if the shadow is the same as the current database --
964 // if so, a shadow file is being accessed as a database
965
966 Firebird::PathName expanded_name(file_name);
967 ISC_expand_filename(expanded_name, false);
968 PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
969 jrd_file* dbb_file = pageSpace->file;
970
971 if (dbb_file && expanded_name == dbb_file->fil_string)
972 {
973 if (shadow && (shadow->sdw_flags & SDW_rollover))
974 return;
975
976 ERR_post(Arg::Gds(isc_shadow_accessed));
977 }
978

Callers

nothing calls this directly

Calls 15

SET_TDBBFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
CCH_FETCHFunction · 0.85
ERR_puntFunction · 0.85
check_for_fileFunction · 0.85
CCH_RELEASEFunction · 0.85
allocate_shadowFunction · 0.85
PAG_init2Function · 0.85
NumClass · 0.85
getDatabaseMethod · 0.80

Tested by

no test coverage detected