* DropRelFileNodeLocalBuffers * This function removes from the buffer pool all the pages of the * specified relation that have block numbers >= firstDelBlock. * (In particular, with firstDelBlock = 0, all pages are removed.) * Dirty pages are simply dropped, without bothering to write them * out first. Therefore, this is NOT rollback-able, and so should be * used only with extreme cau
| 344 | * See DropRelFileNodeBuffers in bufmgr.c for more notes. |
| 345 | */ |
| 346 | void |
| 347 | DropRelFileNodeLocalBuffers(RelFileNode rnode, ForkNumber forkNum, |
| 348 | BlockNumber firstDelBlock) |
| 349 | { |
| 350 | int i; |
| 351 | |
| 352 | /* |
| 353 | * Local buffers are used for temp tables in PostgreSQL. As temp tables |
| 354 | * use shared buffers in Cloudberry, we shouldn't be useing local buffers |
| 355 | * for anything. |
| 356 | */ |
| 357 | Assert(false); |
| 358 | for (i = 0; i < NLocBuffer; i++) |
| 359 | { |
| 360 | BufferDesc *bufHdr = GetLocalBufferDescriptor(i); |
| 361 | LocalBufferLookupEnt *hresult; |
| 362 | uint32 buf_state; |
| 363 | |
| 364 | buf_state = pg_atomic_read_u32(&bufHdr->state); |
| 365 | |
| 366 | if ((buf_state & BM_TAG_VALID) && |
| 367 | RelFileNodeEquals(bufHdr->tag.rnode, rnode) && |
| 368 | bufHdr->tag.forkNum == forkNum && |
| 369 | bufHdr->tag.blockNum >= firstDelBlock) |
| 370 | { |
| 371 | if (LocalRefCount[i] != 0) |
| 372 | elog(ERROR, "block %u of %s is still referenced (local %u)", |
| 373 | bufHdr->tag.blockNum, |
| 374 | relpathbackend(bufHdr->tag.rnode, MyBackendId, |
| 375 | bufHdr->tag.forkNum), |
| 376 | LocalRefCount[i]); |
| 377 | /* Remove entry from hashtable */ |
| 378 | hresult = (LocalBufferLookupEnt *) |
| 379 | hash_search(LocalBufHash, (void *) &bufHdr->tag, |
| 380 | HASH_REMOVE, NULL); |
| 381 | if (!hresult) /* shouldn't happen */ |
| 382 | elog(ERROR, "local buffer hash table corrupted"); |
| 383 | /* Mark buffer invalid */ |
| 384 | CLEAR_BUFFERTAG(bufHdr->tag); |
| 385 | buf_state &= ~BUF_FLAG_MASK; |
| 386 | buf_state &= ~BUF_USAGECOUNT_MASK; |
| 387 | pg_atomic_unlocked_write_u32(&bufHdr->state, buf_state); |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | /* |
| 393 | * DropRelFileNodeAllLocalBuffers |
no test coverage detected