Commit 30aaab26 authored by Peter Geoghegan's avatar Peter Geoghegan

PageAddItemExtended(): Add LP_UNUSED assertion.

Assert that LP_UNUSED items have no storage.  If it's worth having
defensive code in non-assert builds then it's worth having an assertion
as well.
parent f58b230e
...@@ -250,14 +250,18 @@ PageAddItemExtended(Page page, ...@@ -250,14 +250,18 @@ PageAddItemExtended(Page page,
/* if no free slot, we'll put it at limit (1st open slot) */ /* if no free slot, we'll put it at limit (1st open slot) */
if (PageHasFreeLinePointers(phdr)) if (PageHasFreeLinePointers(phdr))
{ {
/* /* Look for "recyclable" (unused) ItemId */
* Look for "recyclable" (unused) ItemId. We check for no storage
* as well, just to be paranoid --- unused items should never have
* storage.
*/
for (offsetNumber = 1; offsetNumber < limit; offsetNumber++) for (offsetNumber = 1; offsetNumber < limit; offsetNumber++)
{ {
itemId = PageGetItemId(phdr, offsetNumber); itemId = PageGetItemId(phdr, offsetNumber);
/*
* We check for no storage as well, just to be paranoid;
* unused items should never have storage. Assert() that the
* invariant is respected too.
*/
Assert(ItemIdIsUsed(itemId) || !ItemIdHasStorage(itemId));
if (!ItemIdIsUsed(itemId) && !ItemIdHasStorage(itemId)) if (!ItemIdIsUsed(itemId) && !ItemIdHasStorage(itemId))
break; break;
} }
...@@ -676,7 +680,9 @@ compactify_tuples(itemIdCompact itemidbase, int nitems, Page page, bool presorte ...@@ -676,7 +680,9 @@ compactify_tuples(itemIdCompact itemidbase, int nitems, Page page, bool presorte
* *
* This routine is usable for heap pages only, but see PageIndexMultiDelete. * This routine is usable for heap pages only, but see PageIndexMultiDelete.
* *
* As a side effect, the page's PD_HAS_FREE_LINES hint bit is updated. * Caller had better have a super-exclusive lock on page's buffer. As a side
* effect the page's PD_HAS_FREE_LINES hint bit will be set or unset as
* needed.
*/ */
void void
PageRepairFragmentation(Page page) PageRepairFragmentation(Page page)
...@@ -771,7 +777,7 @@ PageRepairFragmentation(Page page) ...@@ -771,7 +777,7 @@ PageRepairFragmentation(Page page)
compactify_tuples(itemidbase, nstorage, page, presorted); compactify_tuples(itemidbase, nstorage, page, presorted);
} }
/* Set hint bit for PageAddItem */ /* Set hint bit for PageAddItemExtended */
if (nunused > 0) if (nunused > 0)
PageSetHasFreeLinePointers(page); PageSetHasFreeLinePointers(page);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment