1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

There already was a macro PageGetItemId; this is now used in (almost)

all places, where pd_linp is accessed.  Also introduce new macros
SizeOfPageHeaderData and BTMaxItemSize. This is just source code
cosmetic, no behaviour changed.

Manfred Koizar
This commit is contained in:
Bruce Momjian
2002-07-02 05:48:44 +00:00
parent 8864603f3c
commit 33f1687879
6 changed files with 58 additions and 42 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.140 2002/07/02 05:46:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.141 2002/07/02 05:48:44 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -2067,7 +2067,7 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record)
while ((char *) unused < unend)
{
lp = ((PageHeader) page)->pd_linp + *unused;
lp = PageGetItemId(page, *unused + 1);
lp->lp_flags &= ~LP_USED;
unused++;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.93 2002/06/20 20:29:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.94 2002/07/02 05:48:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -383,10 +383,9 @@ _bt_insertonpg(Relation rel,
* to 1/3 the per-page available space. Note that at this point,
* itemsz doesn't include the ItemId.
*/
if (itemsz > (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
if (itemsz > BTMaxItemSize(page))
elog(ERROR, "btree: index item size %lu exceeds maximum %lu",
(unsigned long) itemsz,
(PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData));
(unsigned long) itemsz, BTMaxItemSize(page));
/*
* Determine exactly where new item will go.
@@ -1020,9 +1019,8 @@ _bt_findsplitloc(Relation rel,
/* Total free space available on a btree page, after fixed overhead */
leftspace = rightspace =
PageGetPageSize(page) - sizeof(PageHeaderData) -
MAXALIGN(sizeof(BTPageOpaqueData))
+sizeof(ItemIdData);
PageGetPageSize(page) - SizeOfPageHeaderData -
MAXALIGN(sizeof(BTPageOpaqueData));
/*
* Finding the best possible split would require checking all the

View File

@@ -35,7 +35,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.64 2002/06/20 20:29:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.65 2002/07/02 05:48:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -346,10 +346,9 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti)
* oversize items being inserted into an already-existing index. But
* during creation of an index, we don't go through there.
*/
if (btisz > (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
if (btisz > BTMaxItemSize(npage))
elog(ERROR, "btree: index item size %lu exceeds maximum %ld",
(unsigned long) btisz,
(PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData));
(unsigned long) btisz, BTMaxItemSize(npage));
if (pgspc < btisz || pgspc < state->btps_full)
{