Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D4278650E8F for ; Fri, 4 Jul 2008 07:54:12 -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 95011-07 for ; Fri, 4 Jul 2008 07:54:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gmp-eb-inf-2.sun.com (gmp-eb-inf-2.sun.com [192.18.6.24]) by postgresql.org (Postfix) with ESMTP id F059A650E7F for ; Fri, 4 Jul 2008 07:54:08 -0300 (ADT) Received: from fe-emea-09.sun.com (gmp-eb-lb-2-fe2.eu.sun.com [192.18.6.11]) by gmp-eb-inf-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m64As6wn012934 for ; Fri, 4 Jul 2008 10:54:06 GMT Received: from conversion-daemon.fe-emea-09.sun.com by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K3H00M0192X2B00@fe-emea-09.sun.com> (original mail from Zdenek.Kotala@Sun.COM) for pgsql-patches@postgresql.org; Fri, 04 Jul 2008 11:54:06 +0100 (BST) Received: from [192.168.1.101] ([89.103.109.2]) by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0K3H00AM7A9F2P00@fe-emea-09.sun.com>; Fri, 04 Jul 2008 11:53:40 +0100 (BST) Date: Fri, 04 Jul 2008 12:50:55 +0200 From: Zdenek Kotala Subject: Re: page macros cleanup In-reply-to: <486DF644.4070604@enterprisedb.com> To: Heikki Linnakangas Cc: Pavan Deolasee , PostgreSQL-patches Message-id: <486E008F.3080304@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT References: <48529B83.9010907@sun.com> <2e78013d0807030450m4cab60d0jd99d1acce59fae56@mail.gmail.com> <486DD1D1.50604@sun.com> <2e78013d0807040150w393ad72codaf06a6ac12a83ce@mail.gmail.com> <486DF644.4070604@enterprisedb.com> User-Agent: Thunderbird 2.0.0.12 (X11/20080325) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/58 X-Sequence-Number: 6752 Heikki Linnakangas napsal(a): > 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. Are you sure? I expecting that tupleheader must be aligned to MAXALIGN. If it is not required than you are right. Look on PageAddItem: 00226 alignedSize = MAXALIGN(size); 00227 00228 upper = (int) phdr->pd_upper - (int) alignedSize; By my opinion first place where tuple should be placed is: MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData)) > 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. > Yeah, BLKCSZ looks good. Anyway, I plan to reorganize all *MaxItemSize staff to be compatible with in-place upgrade. thanks Zdenek -- Zdenek Kotala Sun Microsystems Prague, Czech Republic http://sun.com/postgresql