Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit984d0a1

Browse files
committed
In PageIndexTupleDelete, don't assume stored item lengths are MAXALIGNed.
PageAddItem stores the item length as-is. It MAXALIGN's the amount ofspace actually allocated for each tuple, but not the stored length.PageRepairFragmentation, PageIndexMultiDelete, and PageIndexDeleteNoCompactare all on board with this and MAXALIGN item lengths after fetching them.But PageIndexTupleDelete expects the stored length to be a MAXALIGNmultiple already. This accidentally works for existing index AMs becausethey all maxalign their tuple sizes internally; but we don't do that forheap tuples, and it shouldn't be a requirement for index tuples either.So, sync PageIndexTupleDelete with the rest of bufpage.c by having itmaxalign the item size after fetching.Also add a check that pd_special is maxaligned, to ensure that the test"(offset + size) > phdr->pd_special" is still doing the right thing.(If offset and pd_special are aligned, it doesn't matter whether size is.)Again, this is in sync with the rest of the routines here, except forPageAddItem which doesn't test because it doesn't actually do anythingfor which pd_special alignment matters.This shouldn't have any immediate functional impact; it just adds theflexibility to use PageIndexTupleDelete on index tuples with non-alignedlengths.Discussion: <3814.1473366762@sss.pgh.pa.us>
1 parente0013de commit984d0a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/backend/storage/page/bufpage.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
738738
if (phdr->pd_lower<SizeOfPageHeaderData||
739739
phdr->pd_lower>phdr->pd_upper||
740740
phdr->pd_upper>phdr->pd_special||
741-
phdr->pd_special>BLCKSZ)
741+
phdr->pd_special>BLCKSZ||
742+
phdr->pd_special!=MAXALIGN(phdr->pd_special))
742743
ereport(ERROR,
743744
(errcode(ERRCODE_DATA_CORRUPTED),
744745
errmsg("corrupted page pointers: lower = %u, upper = %u, special = %u",
@@ -757,12 +758,15 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
757758
offset=ItemIdGetOffset(tup);
758759

759760
if (offset<phdr->pd_upper|| (offset+size)>phdr->pd_special||
760-
offset!=MAXALIGN(offset)||size!=MAXALIGN(size))
761+
offset!=MAXALIGN(offset))
761762
ereport(ERROR,
762763
(errcode(ERRCODE_DATA_CORRUPTED),
763764
errmsg("corrupted item pointer: offset = %u, size = %u",
764765
offset, (unsignedint)size)));
765766

767+
/* Amount of space to actually be deleted */
768+
size=MAXALIGN(size);
769+
766770
/*
767771
* First, we want to get rid of the pd_linp entry for the index tuple. We
768772
* copy all subsequent linp's back one slot in the array. We don't use

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp