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

Method walk_pip

src/jrd/validation.cpp:2438–2565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2436}
2437
2438void Validation::walk_pip()
2439{
2440/**************************************
2441 *
2442 * w a l k _ p i p
2443 *
2444 **************************************
2445 *
2446 * Functional description
2447 * Walk the page inventory pages.
2448 *
2449 **************************************/
2450 Database* dbb = vdr_tdbb->getDatabase();
2451
2452 PageManager& pageSpaceMgr = dbb->dbb_page_manager;
2453 const PageSpace* pageSpace = pageSpaceMgr.findPageSpace(DB_PAGE_SPACE);
2454 fb_assert(pageSpace);
2455
2456 page_inv_page* page = 0;
2457
2458 for (USHORT sequence = 0; true; sequence++)
2459 {
2460 const ULONG page_number =
2461 sequence ? sequence * pageSpaceMgr.pagesPerPIP - 1 : pageSpace->pipFirst;
2462#ifdef DEBUG_VAL_VERBOSE
2463 if (VAL_debug_level)
2464 fprintf(stdout, "walk_pip: page %d\n", page_number);
2465#endif
2466 WIN window(DB_PAGE_SPACE, -1);
2467 fetch_page(true, page_number, pag_pages, &window, &page);
2468
2469 ULONG pipMin = MAX_ULONG;
2470 ULONG pipExtent = MAX_ULONG;
2471 ULONG pipUsed = 0;
2472
2473 UCHAR* bytes = page->pip_bits;
2474 const UCHAR* end = (UCHAR*) page + dbb->dbb_page_size;
2475 for (; bytes < end; bytes++)
2476 {
2477 if (*bytes == 0)
2478 {
2479 pipUsed = (bytes - page->pip_bits + 1) * 8;
2480 continue;
2481 }
2482
2483 if (*bytes == 0xFF && pipExtent == MAX_ULONG)
2484 pipExtent = (bytes - page->pip_bits) * 8;
2485
2486 if (pipMin == MAX_ULONG)
2487 {
2488 UCHAR mask = 1;
2489 for (int i = 0; i < 8; i++, mask <<= 1)
2490 {
2491 if (*bytes & mask)
2492 {
2493 pipMin = (bytes - page->pip_bits) * 8 + i;
2494 break;
2495 }

Callers

nothing calls this directly

Calls 4

corruptFunction · 0.85
CCH_MARKFunction · 0.85
getDatabaseMethod · 0.80
findPageSpaceMethod · 0.80

Tested by

no test coverage detected