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

Function CCH_write_all_shadows

src/jrd/cch.cpp:2424–2545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2422
2423
2424bool CCH_write_all_shadows(thread_db* tdbb, Shadow* shadow, BufferDesc* bdb, Ods::pag* page,
2425 FbStatusVector* status, const bool inAst)
2426{
2427/**************************************
2428 *
2429 * C C H _ w r i t e _ a l l _ s h a d o w s
2430 *
2431 **************************************
2432 *
2433 * Functional description
2434 * Compute a checksum and write a page out to all shadows
2435 * detecting failure on write.
2436 * If shadow is null, write to all shadows, otherwise only to specified
2437 * shadow.
2438 *
2439 **************************************/
2440 SET_TDBB(tdbb);
2441 Database* dbb = tdbb->getDatabase();
2442
2443 Shadow* sdw = shadow ? shadow : dbb->dbb_shadow;
2444
2445 if (!sdw)
2446 return true;
2447
2448 bool result = true;
2449 Firebird::UCharBuffer spare_buffer;
2450
2451 if (bdb->bdb_page == HEADER_PAGE_NUMBER)
2452 {
2453 Ods::pag* newPage = (pag*) spare_buffer.getBuffer(dbb->dbb_page_size);
2454 memcpy(newPage, page, HDR_SIZE);
2455 page = newPage;
2456 memset((UCHAR*) page + HDR_SIZE, 0, dbb->dbb_page_size - HDR_SIZE);
2457 }
2458 page->pag_pageno = bdb->bdb_page.getPageNum();
2459
2460 for (; sdw; sdw = sdw->sdw_next)
2461 {
2462 // don't bother to write to the shadow if it is no longer viable
2463
2464 /* Fix for bug 7925. drop_gdb fails to remove secondary file if
2465 the shadow is conditional. Reason being the header page not
2466 being correctly initialized.
2467
2468 The following block was not being performed for a conditional
2469 shadow since SDW_INVALID expanded to include conditional shadow
2470
2471 -Sudesh 07/10/95
2472 old code --> if (sdw->sdw_flags & SDW_INVALID)
2473 */
2474
2475 if ((sdw->sdw_flags & SDW_INVALID) && !(sdw->sdw_flags & SDW_conditional))
2476 continue;
2477
2478 if (bdb->bdb_page == HEADER_PAGE_NUMBER)
2479 {
2480 // fixup header for shadow file
2481 jrd_file* shadow_file = sdw->sdw_file;

Callers 3

callbackMethod · 0.85
SDW_addFunction · 0.85
callbackMethod · 0.85

Calls 14

SET_TDBBFunction · 0.85
PAG_add_header_entryFunction · 0.85
SDW_check_conditionalFunction · 0.85
SDW_lck_updateFunction · 0.85
SDW_notifyFunction · 0.85
CCH_unwindFunction · 0.85
SDW_dump_pagesFunction · 0.85
GdsClass · 0.85
getDatabaseMethod · 0.80
getPageNumMethod · 0.80
findPageSpaceMethod · 0.80
ERR_postFunction · 0.70

Tested by

no test coverage detected