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

Function TRA_update_counters

src/jrd/tra.cpp:897–948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

895
896
897void TRA_update_counters(thread_db* tdbb, Database* dbb)
898{
899/**************************************
900*
901* T R A _ u p d a t e _ c o u n t e r s
902*
903**************************************
904*
905* Functional description
906* Update header page using cached values of transactions counters
907*
908**************************************/
909 SET_TDBB(tdbb);
910
911 if (!dbb || dbb->dbb_flags & DBB_read_only || dbb->dbb_flags & DBB_new ||
912 dbb->dbb_oldest_transaction == 0)
913 {
914 return;
915 }
916
917 WIN window(HEADER_PAGE_NUMBER);
918 header_page* header = (header_page*)CCH_FETCH(tdbb, &window, LCK_write, pag_header);
919
920 const TraNumber next_transaction = Ods::getNT(header);
921 const TraNumber oldest_transaction = Ods::getOIT(header);
922 const TraNumber oldest_active = Ods::getOAT(header);
923 const TraNumber oldest_snapshot = Ods::getOST(header);
924
925 fb_assert(dbb->dbb_next_transaction <= next_transaction);
926
927 if (dbb->dbb_oldest_active > oldest_active ||
928 dbb->dbb_oldest_transaction > oldest_transaction ||
929 dbb->dbb_oldest_snapshot > oldest_snapshot ||
930 dbb->dbb_next_transaction > next_transaction)
931 {
932 CCH_MARK_MUST_WRITE(tdbb, &window);
933
934 if (dbb->dbb_oldest_active > oldest_active)
935 Ods::writeOAT(header, dbb->dbb_oldest_active);
936
937 if (dbb->dbb_oldest_transaction > oldest_transaction)
938 Ods::writeOIT(header, dbb->dbb_oldest_transaction);
939
940 if (dbb->dbb_oldest_snapshot > oldest_snapshot)
941 Ods::writeOST(header, dbb->dbb_oldest_snapshot);
942
943 if (dbb->dbb_next_transaction > next_transaction)
944 Ods::writeNT(header, dbb->dbb_next_transaction);
945 }
946
947 CCH_RELEASE(tdbb, &window);
948}
949
950
951void TRA_post_resources(thread_db* tdbb, jrd_tra* transaction, ResourceList& resources)

Callers 2

JRD_shutdown_databaseFunction · 0.85
start_sweeperFunction · 0.85

Calls 12

SET_TDBBFunction · 0.85
CCH_FETCHFunction · 0.85
getNTFunction · 0.85
getOITFunction · 0.85
getOATFunction · 0.85
getOSTFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
writeOATFunction · 0.85
writeOITFunction · 0.85
writeOSTFunction · 0.85
writeNTFunction · 0.85
CCH_RELEASEFunction · 0.85

Tested by

no test coverage detected