Re: [HACKERS] PageGetMaxOffsetNumber on uninitialized pages

2004-06-04 Thread Gaetano Mendola
Tom Lane wrote: I was just looking at this macro: /* * 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

Re: [HACKERS] PageGetMaxOffsetNumber on uninitialized pages

2004-06-04 Thread Gaetano Mendola
Gaetano Mendola wrote: Tom Lane wrote: We could fix this by changing the declarations of the maxoff variables to int, but I think it's probably cleaner to recode PageGetMaxOffsetNumber like so: #define PageGetMaxOffsetNumber(page) \ (((PageHeader) (page))-pd_lower = SizeOfPageHeaderData ? 0 :

[HACKERS] PageGetMaxOffsetNumber on uninitialized pages

2004-06-03 Thread Tom Lane
I was just looking at this macro: /* * 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

Re: [HACKERS] PageGetMaxOffsetNumber

2002-12-16 Thread Manfred Koizar
On Sun, 15 Dec 2002 23:49:57 -0300, Alvaro Herrera [EMAIL PROTECTED] wrote: PageGetMaxOffsetNumber (the upper bound) returns a consistent value that's far too high (4294967291, 0xFFFB) Alvaro, maybe this comment from bufpage.h can shed some light on it? /* * PageGetMaxOffsetNumber *

Re: [HACKERS] PageGetMaxOffsetNumber

2002-12-16 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes: ppage = BufferGetPage(pbuf); pop = (BTPageOpaque) PageGetSpecialPointer(ppage); max = PageGetMaxOffsetNumber(pop); I believe you want PageGetMaxOffsetNumber(ppage) ... regards, tom lane

[HACKERS] PageGetMaxOffsetNumber

2002-12-15 Thread Alvaro Herrera
Hello hackers, I wonder what the PageGetMaxOffsetNumber macro is supposed to do (in a btree index page)? The scenario is the following: I need to get the pointer to a btree page (leaf or internal) in its parent page, to call _bt_itemdel on it. The only thing I can think of is to use its parent

Re: [HACKERS] PageGetMaxOffsetNumber

2002-12-15 Thread Alvaro Herrera
On Sun, Dec 15, 2002 at 11:49:57PM -0300, Alvaro Herrera wrote: I iterate over the elements of the parent page in a for loop, and the upper bound is rarely reached because the item is found. However sometimes the item isn't found, and PageGetItem fails its assertion because the item isn't