Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 98172650EA5 for ; Fri, 4 Jul 2008 07:09:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 54136-03 for ; Fri, 4 Jul 2008 07:09:35 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail01.enterprisedb.com (webmail.enterprisedb.com [63.246.7.168]) by postgresql.org (Postfix) with ESMTP id 59FE064FD64 for ; Fri, 4 Jul 2008 07:07:24 -0300 (ADT) thread-index: Acjdvd4oEvGOq/JwQC2JKe55DTUq7A== Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 Received: from [80.222.70.18] ([80.222.70.18]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Fri, 4 Jul 2008 06:08:11 -0400 Message-ID: <486DF644.4070604@enterprisedb.com> Date: Fri, 04 Jul 2008 13:07:00 +0300 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509) MIME-Version: 1.0 To: "Pavan Deolasee" Cc: "Zdenek Kotala" , "PostgreSQL-patches" Subject: Re: page macros cleanup References: <48529B83.9010907@sun.com> <2e78013d0807030450m4cab60d0jd99d1acce59fae56@mail.gmail.com> <486DD1D1.50604@sun.com> <2e78013d0807040150w393ad72codaf06a6ac12a83ce@mail.gmail.com> In-Reply-To: <2e78013d0807040150w393ad72codaf06a6ac12a83ce@mail.gmail.com> Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 04 Jul 2008 10:08:12.0468 (UTC) FILETIME=[DE173740:01C8DDBD] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/56 X-Sequence-Number: 6750 Pavan Deolasee wrote: > On Fri, Jul 4, 2008 at 1:01 PM, Zdenek Kotala 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