diff options
Diffstat (limited to 'src/backend/storage')
-rw-r--r-- | src/backend/storage/page/bufpage.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 6bd38127105..4f580fa9b5f 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -15,6 +15,7 @@ #include "postgres.h" #include "access/htup.h" +#include "access/itup.h" #include "storage/bufpage.h" @@ -363,8 +364,6 @@ PageRepairFragmentation(Page page) Offset pd_lower = ((PageHeader) page)->pd_lower; Offset pd_upper = ((PageHeader) page)->pd_upper; Offset pd_special = ((PageHeader) page)->pd_special; - itemIdSort itemidbase, - itemidptr; ItemId lp; int nline, nstorage, @@ -414,10 +413,11 @@ PageRepairFragmentation(Page page) ((PageHeader) page)->pd_upper = pd_special; } else - { /* nstorage != 0 */ + { /* Need to compact the page the hard way */ - itemidbase = (itemIdSort) palloc(sizeof(itemIdSortData) * nstorage); - itemidptr = itemidbase; + itemIdSortData itemidbase[MaxHeapTuplesPerPage]; + itemIdSort itemidptr = itemidbase; + totallen = 0; for (i = 0; i < nline; i++) { @@ -462,8 +462,6 @@ PageRepairFragmentation(Page page) } ((PageHeader) page)->pd_upper = upper; - - pfree(itemidbase); } /* Set hint bit for PageAddItem */ @@ -712,8 +710,8 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems) Offset pd_lower = phdr->pd_lower; Offset pd_upper = phdr->pd_upper; Offset pd_special = phdr->pd_special; - itemIdSort itemidbase, - itemidptr; + itemIdSortData itemidbase[MaxIndexTuplesPerPage]; + itemIdSort itemidptr; ItemId lp; int nline, nused; @@ -725,6 +723,8 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems) int nextitm; OffsetNumber offnum; + Assert(nitems < MaxIndexTuplesPerPage); + /* * If there aren't very many items to delete, then retail * PageIndexTupleDelete is the best way. Delete the items in reverse @@ -759,7 +759,6 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems) * still validity-checking. */ nline = PageGetMaxOffsetNumber(page); - itemidbase = (itemIdSort) palloc(sizeof(itemIdSortData) * nline); itemidptr = itemidbase; totallen = 0; nused = 0; @@ -825,6 +824,4 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems) phdr->pd_lower = SizeOfPageHeaderData + nused * sizeof(ItemIdData); phdr->pd_upper = upper; - - pfree(itemidbase); } |