Re: Replace offnum++ by OffsetNumberNext

Lists: pgsql-patches
From: Fujii Masao <fujii(dot)masao(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Subject: Replace offnum++ by OffsetNumberNext
Date: 2008-04-04 15:13:30
Message-ID: 47F6459A.4040700@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

This is the patch replace offnum++ by OffsetNumberNext.

According to off.h, OffsetNumberNext is the macro prepared to
disambiguate the different manipulations on OffsetNumbers.
But, increment operator was used in some places instead of the macro.

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
TEL (03)5860-5115
FAX (03)5463-5490

Attachment Content-Type Size
offnum.patch text/plain 3.1 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <fujii(dot)masao(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Replace offnum++ by OffsetNumberNext
Date: 2008-04-04 21:04:23
Message-ID: 8309.1207343063@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Fujii Masao <fujii(dot)masao(at)oss(dot)ntt(dot)co(dot)jp> writes:
> This is the patch replace offnum++ by OffsetNumberNext.
> According to off.h, OffsetNumberNext is the macro prepared to
> disambiguate the different manipulations on OffsetNumbers.
> But, increment operator was used in some places instead of the macro.

I wonder if we shouldn't go the other way, ie, use ++ everywhere.
OffsetNumberNext seems like just useless obscurantism ...

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Fujii Masao <fujii(dot)masao(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Replace offnum++ by OffsetNumberNext
Date: 2008-05-10 00:50:03
Message-ID: 200805100050.m4A0o3H25811@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Fujii Masao <fujii(dot)masao(at)oss(dot)ntt(dot)co(dot)jp> writes:
> > This is the patch replace offnum++ by OffsetNumberNext.
> > According to off.h, OffsetNumberNext is the macro prepared to
> > disambiguate the different manipulations on OffsetNumbers.
> > But, increment operator was used in some places instead of the macro.
>
> I wonder if we shouldn't go the other way, ie, use ++ everywhere.
> OffsetNumberNext seems like just useless obscurantism ...

The only value I saw to OffsetNumberNext was the fact is does int16
increment, with casting. There is also the comment:

* Increments/decrements the argument. These macros look pointless
* but they help us disambiguate the different manipulations on
* OffsetNumbers (e.g., sometimes we subtract one from an
* OffsetNumber to move back, and sometimes we do so to form a
* real C array index).

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Fujii Masao <fujii(dot)masao(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Replace offnum++ by OffsetNumberNext
Date: 2008-05-13 15:46:14
Message-ID: 200805131546.m4DFkEB03832@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

Fujii Masao wrote:
> This is the patch replace offnum++ by OffsetNumberNext.
>
> According to off.h, OffsetNumberNext is the macro prepared to
> disambiguate the different manipulations on OffsetNumbers.
> But, increment operator was used in some places instead of the macro.
>
> --
> Fujii Masao
> NIPPON TELEGRAPH AND TELEPHONE CORPORATION
> NTT Open Source Software Center
> TEL (03)5860-5115
> FAX (03)5463-5490

> ? patch.diff
> Index: src/backend/access/heap/pruneheap.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/backend/access/heap/pruneheap.c,v
> retrieving revision 1.9
> diff -c -r1.9 pruneheap.c
> *** src/backend/access/heap/pruneheap.c 26 Mar 2008 21:10:37 -0000 1.9
> --- src/backend/access/heap/pruneheap.c 4 Apr 2008 14:34:19 -0000
> ***************
> *** 789,795 ****
> MemSet(root_offsets, 0, MaxHeapTuplesPerPage * sizeof(OffsetNumber));
>
> maxoff = PageGetMaxOffsetNumber(page);
> ! for (offnum = FirstOffsetNumber; offnum <= maxoff; offnum++)
> {
> ItemId lp = PageGetItemId(page, offnum);
> HeapTupleHeader htup;
> --- 789,795 ----
> MemSet(root_offsets, 0, MaxHeapTuplesPerPage * sizeof(OffsetNumber));
>
> maxoff = PageGetMaxOffsetNumber(page);
> ! for (offnum = FirstOffsetNumber; offnum <= maxoff; offnum = OffsetNumberNext(offnum))
> {
> ItemId lp = PageGetItemId(page, offnum);
> HeapTupleHeader htup;
> Index: src/backend/executor/nodeBitmapHeapscan.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/backend/executor/nodeBitmapHeapscan.c,v
> retrieving revision 1.25
> diff -c -r1.25 nodeBitmapHeapscan.c
> *** src/backend/executor/nodeBitmapHeapscan.c 26 Mar 2008 21:10:38 -0000 1.25
> --- src/backend/executor/nodeBitmapHeapscan.c 4 Apr 2008 14:34:19 -0000
> ***************
> *** 301,307 ****
> OffsetNumber maxoff = PageGetMaxOffsetNumber(dp);
> OffsetNumber offnum;
>
> ! for (offnum = FirstOffsetNumber; offnum <= maxoff; offnum++)
> {
> ItemId lp;
> HeapTupleData loctup;
> --- 301,307 ----
> OffsetNumber maxoff = PageGetMaxOffsetNumber(dp);
> OffsetNumber offnum;
>
> ! for (offnum = FirstOffsetNumber; offnum <= maxoff; offnum = OffsetNumberNext(offnum))
> {
> ItemId lp;
> HeapTupleData loctup;
> Index: src/backend/storage/page/bufpage.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/backend/storage/page/bufpage.c,v
> retrieving revision 1.78
> diff -c -r1.78 bufpage.c
> *** src/backend/storage/page/bufpage.c 10 Feb 2008 20:39:08 -0000 1.78
> --- src/backend/storage/page/bufpage.c 4 Apr 2008 14:34:19 -0000
> ***************
> *** 533,539 ****
> * Since this is just a hint, we must confirm that there is
> * indeed a free line pointer
> */
> ! for (offnum = FirstOffsetNumber; offnum <= nline; offnum++)
> {
> ItemId lp = PageGetItemId(page, offnum);
>
> --- 533,539 ----
> * Since this is just a hint, we must confirm that there is
> * indeed a free line pointer
> */
> ! for (offnum = FirstOffsetNumber; offnum <= nline; offnum = OffsetNumberNext(offnum))
> {
> ItemId lp = PageGetItemId(page, offnum);
>
> ***************
> *** 736,742 ****
> totallen = 0;
> nused = 0;
> nextitm = 0;
> ! for (offnum = 1; offnum <= nline; offnum++)
> {
> lp = PageGetItemId(page, offnum);
> Assert(ItemIdHasStorage(lp));
> --- 736,742 ----
> totallen = 0;
> nused = 0;
> nextitm = 0;
> ! for (offnum = FirstOffsetNumber; offnum <= nline; offnum = OffsetNumberNext(offnum))
> {
> lp = PageGetItemId(page, offnum);
> Assert(ItemIdHasStorage(lp));
>
>
> --
> Sent via pgsql-patches mailing list (pgsql-patches(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-patches

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +