mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Set PD_ALL_VISIBLE and visibility map bits in COPY FREEZE
Make sure COPY FREEZE marks the pages as PD_ALL_VISIBLE and updates the visibility map. Until now we only marked individual tuples as frozen, but page-level flags were not updated, so the first VACUUM after the COPY FREEZE had to rewrite the whole table. This is a fairly old patch, and multiple people worked on it. The first version was written by Jeff Janes, and then reworked by Pavan Deolasee and Anastasia Lubennikova. Author: Anastasia Lubennikova, Pavan Deolasee, Jeff Janes Reviewed-by: Kuntal Ghosh, Jeff Janes, Tomas Vondra, Masahiko Sawada, Andres Freund, Ibrar Ahmed, Robert Haas, Tatsuro Ishii, Darafei Praliaskouski Discussion: https://postgr.es/m/CABOikdN-ptGv0mZntrK2Q8OtfUuAjqaYMGmkdU1dCKFtUxVLrg@mail.gmail.com Discussion: https://postgr.es/m/CAMkU%3D1w3osJJ2FneELhhNRLxfZitDgp9FPHee08NT2FQFmz_pQ%40mail.gmail.com
This commit is contained in:
@@ -433,6 +433,14 @@ loop:
|
||||
buffer = ReadBufferBI(relation, targetBlock, RBM_NORMAL, bistate);
|
||||
if (PageIsAllVisible(BufferGetPage(buffer)))
|
||||
visibilitymap_pin(relation, targetBlock, vmbuffer);
|
||||
|
||||
/*
|
||||
* If the page is empty, pin vmbuffer to set all_frozen bit later.
|
||||
*/
|
||||
if ((options & HEAP_INSERT_FROZEN) &&
|
||||
(PageGetMaxOffsetNumber(BufferGetPage(buffer)) == 0))
|
||||
visibilitymap_pin(relation, targetBlock, vmbuffer);
|
||||
|
||||
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
|
||||
}
|
||||
else if (otherBlock == targetBlock)
|
||||
@@ -619,6 +627,15 @@ loop:
|
||||
PageInit(page, BufferGetPageSize(buffer), 0);
|
||||
MarkBufferDirty(buffer);
|
||||
|
||||
/*
|
||||
* The page is empty, pin vmbuffer to set all_frozen bit.
|
||||
*/
|
||||
if (options & HEAP_INSERT_FROZEN)
|
||||
{
|
||||
Assert(PageGetMaxOffsetNumber(BufferGetPage(buffer)) == 0);
|
||||
visibilitymap_pin(relation, BufferGetBlockNumber(buffer), vmbuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the file-extension lock; it's now OK for someone else to extend
|
||||
* the relation some more.
|
||||
|
Reference in New Issue
Block a user