| 3177 | |
| 3178 | |
| 3179 | static void check_precedence(thread_db* tdbb, WIN* window, PageNumber page) |
| 3180 | { |
| 3181 | /************************************** |
| 3182 | * |
| 3183 | * c h e c k _ p r e c e d e n c e |
| 3184 | * |
| 3185 | ************************************** |
| 3186 | * |
| 3187 | * Functional description |
| 3188 | * Given a window accessed for write and a page number, |
| 3189 | * establish a precedence relationship such that the |
| 3190 | * specified page will always be written before the page |
| 3191 | * associated with the window. |
| 3192 | * |
| 3193 | * If the "page number" is negative, it is really a transaction |
| 3194 | * id. In this case, the precedence relationship is to the |
| 3195 | * database header page from which the transaction id was |
| 3196 | * obtained. If the header page has been written since the |
| 3197 | * transaction id was assigned, no precedence relationship |
| 3198 | * is required. |
| 3199 | * |
| 3200 | **************************************/ |
| 3201 | SET_TDBB(tdbb); |
| 3202 | Database* dbb = tdbb->getDatabase(); |
| 3203 | BufferControl* bcb = dbb->dbb_bcb; |
| 3204 | |
| 3205 | // If this is really a transaction id, sort things out |
| 3206 | |
| 3207 | switch(page.getPageSpaceID()) |
| 3208 | { |
| 3209 | case DB_PAGE_SPACE: |
| 3210 | break; |
| 3211 | |
| 3212 | case TRANS_PAGE_SPACE: |
| 3213 | if (page.getPageNum() <= tdbb->getDatabase()->dbb_last_header_write) |
| 3214 | return; |
| 3215 | page = PageNumber(DB_PAGE_SPACE, 0); |
| 3216 | break; |
| 3217 | |
| 3218 | default: |
| 3219 | fb_assert(false); |
| 3220 | return; |
| 3221 | } |
| 3222 | |
| 3223 | // In the past negative value, passed here, meant not page, but transaction number. |
| 3224 | // When we finally move to 32 (not 31) bit page numbers, this should be removed, |
| 3225 | // but currently I add: |
| 3226 | fb_assert(!(page.getPageNum() & 0x80000000)); |
| 3227 | // to help detect cases, when something possibly negative is passed. |
| 3228 | // AP - 2011. |
| 3229 | |
| 3230 | // Start by finding the buffer containing the high priority page |
| 3231 | |
| 3232 | #ifndef HASH_USE_CDS_LIST |
| 3233 | Sync bcbSync(&bcb->bcb_syncObject, FB_FUNCTION); |
| 3234 | bcbSync.lock(SYNC_SHARED); |
| 3235 | #endif |
| 3236 |
no test coverage detected