| 2422 | |
| 2423 | |
| 2424 | bool 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; |
no test coverage detected