mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Remove btree page items after page unlink
Currently, page unlink leaves remaining items "as is", but replay of corresponding WAL-record re-initializes page leaving it with no items. For the sake of consistency, this commit makes primary delete all the items during page unlink as well. Thanks to this change, we now don't mask contents of deleted btree page for WAL consistency checking. Discussion: https://postgr.es/m/CAPpHfdt_OTyQpXaPJcWzV2N-LNeNJseNB-K_A66qG%3DL518VTFw%40mail.gmail.com Author: Alexander Korotkov Reviewed-by: Peter Geoghegan
This commit is contained in:
@@ -2058,6 +2058,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
|
||||
BTMetaPageData *metad = NULL;
|
||||
ItemId itemid;
|
||||
Page page;
|
||||
PageHeader header;
|
||||
BTPageOpaque opaque;
|
||||
bool rightsib_is_rightmost;
|
||||
int targetlevel;
|
||||
@@ -2327,6 +2328,14 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
|
||||
opaque->btpo_flags |= BTP_DELETED;
|
||||
opaque->btpo.xact = ReadNewTransactionId();
|
||||
|
||||
/*
|
||||
* Remove the remaining tuples on the page. This keeps things simple for
|
||||
* WAL consistency checking.
|
||||
*/
|
||||
header = (PageHeader) page;
|
||||
header->pd_lower = SizeOfPageHeaderData;
|
||||
header->pd_upper = header->pd_special;
|
||||
|
||||
/* And update the metapage, if needed */
|
||||
if (BufferIsValid(metabuf))
|
||||
{
|
||||
|
@@ -1051,15 +1051,7 @@ btree_mask(char *pagedata, BlockNumber blkno)
|
||||
|
||||
maskopaq = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||
|
||||
if (P_ISDELETED(maskopaq))
|
||||
{
|
||||
/*
|
||||
* Mask page content on a DELETED page since it will be re-initialized
|
||||
* during replay. See btree_xlog_unlink_page() for details.
|
||||
*/
|
||||
mask_page_content(page);
|
||||
}
|
||||
else if (P_ISLEAF(maskopaq))
|
||||
if (P_ISLEAF(maskopaq))
|
||||
{
|
||||
/*
|
||||
* In btree leaf pages, it is possible to modify the LP_FLAGS without
|
||||
|
Reference in New Issue
Block a user