| 895 | |
| 896 | |
| 897 | void 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 | |
| 951 | void TRA_post_resources(thread_db* tdbb, jrd_tra* transaction, ResourceList& resources) |
no test coverage detected