Commit 4f915cd3 authored by Bruce Momjian's avatar Bruce Momjian

This patch cleans up the access to members of ItemIdData.

It uses existing macros instead of touching directly.

ITAGAKI Takahiro
parent 62da04f8
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.65 2005/06/06 20:22:58 tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.66 2005/09/22 16:45:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -149,8 +149,7 @@ PageAddItem(Page page,
if (offsetNumber < limit)
{
itemId = PageGetItemId(phdr, offsetNumber);
if ((itemId->lp_flags & LP_USED) ||
(itemId->lp_len != 0))
if (ItemIdIsUsed(itemId) || ItemIdGetLength(itemId) != 0)
{
elog(WARNING, "will not overwrite a used ItemId");
return InvalidOffsetNumber;
......@@ -170,8 +169,7 @@ PageAddItem(Page page,
for (offsetNumber = 1; offsetNumber < limit; offsetNumber++)
{
itemId = PageGetItemId(phdr, offsetNumber);
if (((itemId->lp_flags & LP_USED) == 0) &&
(itemId->lp_len == 0))
if (!ItemIdIsUsed(itemId) && ItemIdGetLength(itemId) == 0)
break;
}
/* if no free slot, we'll put it at limit (1st open slot) */
......@@ -341,9 +339,9 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
for (i = 0; i < nline; i++)
{
lp = PageGetItemId(page, i + 1);
if (lp->lp_flags & LP_DELETE) /* marked for deletion */
if (ItemIdDeleted(lp)) /* marked for deletion */
lp->lp_flags &= ~(LP_USED | LP_DELETE);
if (lp->lp_flags & LP_USED)
if (ItemIdIsUsed(lp))
nused++;
else if (unused)
unused[i - nused] = (OffsetNumber) i;
......@@ -368,17 +366,17 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
for (i = 0; i < nline; i++)
{
lp = PageGetItemId(page, i + 1);
if (lp->lp_flags & LP_USED)
if (ItemIdIsUsed(lp))
{
itemidptr->offsetindex = i;
itemidptr->itemoff = lp->lp_off;
itemidptr->itemoff = ItemIdGetOffset(lp);
if (itemidptr->itemoff < (int) pd_upper ||
itemidptr->itemoff >= (int) pd_special)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
errmsg("corrupted item pointer: %u",
itemidptr->itemoff)));
itemidptr->alignedlen = MAXALIGN(lp->lp_len);
itemidptr->alignedlen = MAXALIGN(ItemIdGetLength(lp));
totallen += itemidptr->alignedlen;
itemidptr++;
}
......@@ -540,7 +538,7 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
{
ItemId ii = PageGetItemId(phdr, i);
if (ii->lp_off <= offset)
if (ItemIdGetOffset(ii) <= offset)
ii->lp_off += size;
}
}
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.65 2005/04/28 21:47:18 tgl Exp $
* $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.66 2005/09/22 16:46:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -258,8 +258,8 @@ typedef PageHeaderData *PageHeader;
#define PageGetItem(page, itemId) \
( \
AssertMacro(PageIsValid(page)), \
AssertMacro((itemId)->lp_flags & LP_USED), \
(Item)(((char *)(page)) + (itemId)->lp_off) \
AssertMacro(ItemIdIsUsed(itemId)), \
(Item)(((char *)(page)) + ItemIdGetOffset(itemId)) \
)
/*
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/itemid.h,v 1.24 2004/12/31 22:03:42 pgsql Exp $
* $PostgreSQL: pgsql/src/include/storage/itemid.h,v 1.25 2005/09/22 16:46:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -38,7 +38,7 @@ typedef ItemIdData *ItemId;
/*
* This bit may be passed to PageAddItem together with
* LP_USED & LP_DELETED bits to specify overwrite mode
* LP_USED & LP_DELETE bits to specify overwrite mode
*/
#define OverwritePageMode 0x10
......
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