Re: PageGetMaxOffsetNumber

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PageGetMaxOffsetNumber
Date: 2002-12-16 08:58:55
Message-ID: uu4rvugttt7s2knnpa87crh69cm3atfjtr@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 15 Dec 2002 23:49:57 -0300, Alvaro Herrera
<alvherre(at)dcc(dot)uchile(dot)cl> wrote:
>PageGetMaxOffsetNumber (the upper bound) returns a consistent value
>that's far too high (4294967291, 0xFFFFFFFB)

Alvaro, maybe this comment from bufpage.h can shed some light on it?

/*
* PageGetMaxOffsetNumber
* Returns the maximum offset number used by the given page.
* Since offset numbers are 1-based, this is also the number
* of items on the page.
*
* NOTE: to ensure sane behavior if the page is not initialized
* (pd_lower == 0), cast the unsigned values to int before dividing.
* That way we get -1 or so, not a huge positive number...
*/

#define PageGetMaxOffsetNumber(page) \
(((int) (((PageHeader) (page))->pd_lower - SizeOfPageHeaderData)) \
/ ((int) sizeof(ItemIdData)))

0xFFFFFFFB is -5.
With SizeOfPageHeaderData == 20 and sizeof(ItemIdData) == 4 you get
this result for pd_lower == 0.

Servus
Manfred

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve King 2002-12-16 10:56:39 Re: FW: Duplicate oids!
Previous Message Kevin Brown 2002-12-16 07:15:49 Re: [HACKERS] [GENERAL] PostgreSQL Global Development Group