Skip site navigation (1) Skip section navigation (2)

Re: page macros cleanup

From: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
To: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
Cc: "Zdenek Kotala" <Zdenek(dot)Kotala(at)sun(dot)com>,"PostgreSQL-patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: page macros cleanup
Date: 2008-07-04 10:07:00
Message-ID: 486DF644.4070604@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-patches
Pavan Deolasee wrote:
> On Fri, Jul 4, 2008 at 1:01 PM, Zdenek Kotala <Zdenek(dot)Kotala(at)sun(dot)com> wrote:
>>
>> Good catch. I lost in basic arithmetic. What I see now that original
>> definition count sizeof(ItemIdData) twice and on other side it does not take
>> care about MAXALING correctly. I think correct formula is:
>>
>> #define HashMaxItemSize(page) \
>>        (PageGetPageSize(page) - \
>>          ( MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData))+ \
>>            MAXALIGN(sizeof(HashPageOpaqueData)) \
>>          )\
>>         )
>>
>> What do you think?
> 
> Yes. I think that's the correct way.

Doesn't look right to me. There's no padding after the first line 
pointer, hence the first MAXALIGN shouldn't be there.

BTW, looking at hashinsert.c where it's used, we're actually passing a 
pointer to the meta page to HashMaxItemSize(). So the PageGetPageSize() 
call on that is quite bogus, since it's not the meta page that the tuple 
is going to be inserted to. It's academical, because all pages are the 
same size anyway, but doesn't look right. I think I'd go with BLKCSZ 
instead.

I think this is the way it should be:

#define HashMaxItemSize \
	(BLCKSZ - \
	 SizeOfPageHeaderData - \
	 MAXALIGN(sizeof(HashPageOpaqueData)) - \
	 sizeof(ItemIdData))

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

In response to

Responses

pgsql-patches by date

Next:From: Pavan DeolaseeDate: 2008-07-04 10:50:03
Subject: Re: page macros cleanup
Previous:From: Pavel StehuleDate: 2008-07-04 10:01:37
Subject: Re: variadic function support

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group