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

Function CCH_fetch

src/jrd/cch.cpp:774–827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

772
773
774pag* CCH_fetch(thread_db* tdbb, WIN* window, int lock_type, SCHAR page_type, int wait,
775 const bool read_shadow)
776{
777/**************************************
778 *
779 * C C H _ f e t c h
780 *
781 **************************************
782 *
783 * Functional description
784 * Fetch a specific page. If it's already in cache,
785 * so much the better.
786 *
787 * input
788 * wait: 1 => Wait as long as necessary to get the latch.
789 * This can cause deadlocks of course.
790 * 0 => If the latch can't be acquired immediately,
791 * give up and return 0.
792 * <negative number> => Latch timeout interval in seconds.
793 *
794 * return
795 * PAG if successful.
796 * NULL pointer if timeout occurred (only possible if wait <> 1).
797 *
798 **************************************/
799 SET_TDBB(tdbb);
800
801 const LockState lockState = CCH_fetch_lock(tdbb, window, lock_type, wait, page_type);
802 BufferDesc* bdb = window->win_bdb;
803 SyncType syncType = (lock_type >= LCK_write) ? SYNC_EXCLUSIVE : SYNC_SHARED;
804
805 switch (lockState)
806 {
807 case lsLocked:
808 CCH_TRACE(("FE PAGE %d:%06d", window->win_page.getPageSpaceID(), window->win_page.getPageNum()));
809 CCH_fetch_page(tdbb, window, read_shadow); // must read page from disk
810 if (syncType != SYNC_EXCLUSIVE)
811 bdb->downgrade(syncType);
812 break;
813
814 case lsLatchTimeout:
815 case lsLockTimeout:
816 return NULL; // latch or lock timeout
817 }
818
819 adjust_scan_count(window, lockState == lsLocked);
820
821 // Validate the fetched page matches the expected type
822
823 if (bdb->bdb_buffer->pag_type != page_type && page_type != pag_undefined)
824 page_validation_error(tdbb, window, page_type);
825
826 return window->win_buffer;
827}
828
829
830LockState CCH_fetch_lock(thread_db* tdbb, WIN* window, int lock_type, int wait, SCHAR page_type)

Callers 3

CCH_FETCHFunction · 0.70
CCH_FETCH_NO_SHADOWFunction · 0.70
CCH_FETCH_TIMEOUTFunction · 0.70

Calls 8

SET_TDBBFunction · 0.85
CCH_fetch_lockFunction · 0.85
CCH_fetch_pageFunction · 0.85
adjust_scan_countFunction · 0.85
page_validation_errorFunction · 0.85
getPageSpaceIDMethod · 0.80
getPageNumMethod · 0.80
downgradeMethod · 0.45

Tested by

no test coverage detected