Commit ce04221a authored by Bruce Momjian's avatar Bruce Momjian

Stylistic changes in bufmgr.c

	Basically replaces (*a).b with a->b as it is everywhere else in
	Postgres.

Manfred Koizar
parent 5e926cbb
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.57 2003/11/29 19:51:57 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.58 2004/06/08 14:00:35 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -151,8 +151,8 @@ PageAddItem(Page page, ...@@ -151,8 +151,8 @@ PageAddItem(Page page,
if (offsetNumber < limit) if (offsetNumber < limit)
{ {
itemId = PageGetItemId(phdr, offsetNumber); itemId = PageGetItemId(phdr, offsetNumber);
if (((*itemId).lp_flags & LP_USED) || if ((itemId->lp_flags & LP_USED) ||
((*itemId).lp_len != 0)) (itemId->lp_len != 0))
{ {
elog(WARNING, "will not overwrite a used ItemId"); elog(WARNING, "will not overwrite a used ItemId");
return InvalidOffsetNumber; return InvalidOffsetNumber;
...@@ -172,8 +172,8 @@ PageAddItem(Page page, ...@@ -172,8 +172,8 @@ PageAddItem(Page page,
for (offsetNumber = 1; offsetNumber < limit; offsetNumber++) for (offsetNumber = 1; offsetNumber < limit; offsetNumber++)
{ {
itemId = PageGetItemId(phdr, offsetNumber); itemId = PageGetItemId(phdr, offsetNumber);
if ((((*itemId).lp_flags & LP_USED) == 0) && if (((itemId->lp_flags & LP_USED) == 0) &&
((*itemId).lp_len == 0)) (itemId->lp_len == 0))
break; break;
} }
/* 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) */
...@@ -214,9 +214,9 @@ PageAddItem(Page page, ...@@ -214,9 +214,9 @@ PageAddItem(Page page,
(limit - offsetNumber) * sizeof(ItemIdData)); (limit - offsetNumber) * sizeof(ItemIdData));
/* set the item pointer */ /* set the item pointer */
(*itemId).lp_off = upper; itemId->lp_off = upper;
(*itemId).lp_len = size; itemId->lp_len = size;
(*itemId).lp_flags = flags; itemId->lp_flags = flags;
/* copy the item's data onto the page */ /* copy the item's data onto the page */
memcpy((char *) page + upper, item, size); memcpy((char *) page + upper, item, size);
...@@ -278,19 +278,20 @@ PageRestoreTempPage(Page tempPage, Page oldPage) ...@@ -278,19 +278,20 @@ PageRestoreTempPage(Page tempPage, Page oldPage)
/* /*
* sorting support for PageRepairFragmentation * sorting support for PageRepairFragmentation
*/ */
struct itemIdSortData typedef struct itemIdSortData
{ {
int offsetindex; /* linp array index */ int offsetindex; /* linp array index */
int itemoff; /* page offset of item data */ int itemoff; /* page offset of item data */
Size alignedlen; /* MAXALIGN(item data len) */ Size alignedlen; /* MAXALIGN(item data len) */
}; } itemIdSortData;
typedef itemIdSortData *itemIdSort;
static int static int
itemoffcompare(const void *itemidp1, const void *itemidp2) itemoffcompare(const void *itemidp1, const void *itemidp2)
{ {
/* Sort in decreasing itemoff order */ /* Sort in decreasing itemoff order */
return ((struct itemIdSortData *) itemidp2)->itemoff - return ((itemIdSort) itemidp2)->itemoff -
((struct itemIdSortData *) itemidp1)->itemoff; ((itemIdSort) itemidp1)->itemoff;
} }
/* /*
...@@ -309,8 +310,8 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) ...@@ -309,8 +310,8 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
Offset pd_lower = ((PageHeader) page)->pd_lower; Offset pd_lower = ((PageHeader) page)->pd_lower;
Offset pd_upper = ((PageHeader) page)->pd_upper; Offset pd_upper = ((PageHeader) page)->pd_upper;
Offset pd_special = ((PageHeader) page)->pd_special; Offset pd_special = ((PageHeader) page)->pd_special;
struct itemIdSortData *itemidbase, itemIdSort itemidbase,
*itemidptr; itemidptr;
ItemId lp; ItemId lp;
int nline, int nline,
nused; nused;
...@@ -340,9 +341,9 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) ...@@ -340,9 +341,9 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
for (i = 0; i < nline; i++) for (i = 0; i < nline; i++)
{ {
lp = PageGetItemId(page, i + 1); lp = PageGetItemId(page, i + 1);
if ((*lp).lp_flags & LP_DELETE) /* marked for deletion */ if (lp->lp_flags & LP_DELETE) /* marked for deletion */
(*lp).lp_flags &= ~(LP_USED | LP_DELETE); lp->lp_flags &= ~(LP_USED | LP_DELETE);
if ((*lp).lp_flags & LP_USED) if (lp->lp_flags & LP_USED)
nused++; nused++;
else if (unused) else if (unused)
unused[i - nused] = (OffsetNumber) i; unused[i - nused] = (OffsetNumber) i;
...@@ -354,37 +355,36 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) ...@@ -354,37 +355,36 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
for (i = 0; i < nline; i++) for (i = 0; i < nline; i++)
{ {
lp = PageGetItemId(page, i + 1); lp = PageGetItemId(page, i + 1);
(*lp).lp_len = 0; /* indicate unused & deallocated */ lp->lp_len = 0; /* indicate unused & deallocated */
} }
((PageHeader) page)->pd_upper = pd_special; ((PageHeader) page)->pd_upper = pd_special;
} }
else else
{ /* nused != 0 */ { /* nused != 0 */
/* Need to compact the page the hard way */ /* Need to compact the page the hard way */
itemidbase = (struct itemIdSortData *) itemidbase = (itemIdSort) palloc(sizeof(itemIdSortData) * nused);
palloc(sizeof(struct itemIdSortData) * nused);
itemidptr = itemidbase; itemidptr = itemidbase;
totallen = 0; totallen = 0;
for (i = 0; i < nline; i++) for (i = 0; i < nline; i++)
{ {
lp = PageGetItemId(page, i + 1); lp = PageGetItemId(page, i + 1);
if ((*lp).lp_flags & LP_USED) if (lp->lp_flags & LP_USED)
{ {
itemidptr->offsetindex = i; itemidptr->offsetindex = i;
itemidptr->itemoff = (*lp).lp_off; itemidptr->itemoff = lp->lp_off;
if (itemidptr->itemoff < (int) pd_upper || if (itemidptr->itemoff < (int) pd_upper ||
itemidptr->itemoff >= (int) pd_special) itemidptr->itemoff >= (int) pd_special)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("corrupted item pointer: %u", errmsg("corrupted item pointer: %u",
itemidptr->itemoff))); itemidptr->itemoff)));
itemidptr->alignedlen = MAXALIGN((*lp).lp_len); itemidptr->alignedlen = MAXALIGN(lp->lp_len);
totallen += itemidptr->alignedlen; totallen += itemidptr->alignedlen;
itemidptr++; itemidptr++;
} }
else else
{ {
(*lp).lp_len = 0; /* indicate unused & deallocated */ lp->lp_len = 0; /* indicate unused & deallocated */
} }
} }
...@@ -395,7 +395,7 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) ...@@ -395,7 +395,7 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
(unsigned int) totallen, pd_special - pd_lower))); (unsigned int) totallen, pd_special - pd_lower)));
/* sort itemIdSortData array into decreasing itemoff order */ /* sort itemIdSortData array into decreasing itemoff order */
qsort((char *) itemidbase, nused, sizeof(struct itemIdSortData), qsort((char *) itemidbase, nused, sizeof(itemIdSortData),
itemoffcompare); itemoffcompare);
/* compactify page */ /* compactify page */
...@@ -408,7 +408,7 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) ...@@ -408,7 +408,7 @@ PageRepairFragmentation(Page page, OffsetNumber *unused)
memmove((char *) page + upper, memmove((char *) page + upper,
(char *) page + itemidptr->itemoff, (char *) page + itemidptr->itemoff,
itemidptr->alignedlen); itemidptr->alignedlen);
(*lp).lp_off = upper; lp->lp_off = upper;
} }
((PageHeader) page)->pd_upper = upper; ((PageHeader) page)->pd_upper = upper;
...@@ -538,8 +538,9 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) ...@@ -538,8 +538,9 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
nline--; /* there's one less than when we started */ nline--; /* there's one less than when we started */
for (i = 1; i <= nline; i++) for (i = 1; i <= nline; i++)
{ {
if (PageGetItemId(phdr, i)->lp_off <= offset) ItemId ii = PageGetItemId(phdr, i);
PageGetItemId(phdr, i)->lp_off += size; if (ii->lp_off <= offset)
ii->lp_off += size;
} }
} }
} }
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