A slightly misleading comment in GetNewObjectId()

Started by Thomas Munroover 7 years ago4 messageshackers
Jump to latest
#1Thomas Munro
thomas.munro@gmail.com

Hi hackers,

While contemplating plans to use new kinds of OIDs in buffer tags, I
noticed $SUBJECT. It says:

* Check for wraparound of the OID counter. We *must* not return 0
* (InvalidOid); and as long as we have to check that, it seems a good
* idea to skip over everything below FirstNormalObjectId too. (This
* basically just avoids lots of collisions with bootstrap-assigned OIDs
* right after a wrap occurs, so as to avoid a possibly large number of
* iterations in GetNewOid.) Note we are relying on unsigned comparison.

That makes it sound like a mere optimisation, but since commit
8e18d04d4da user-created objects are not allowed to have OIDs below
that threshold. So I propose the attached tweak.

--
Thomas Munro
http://www.enterprisedb.com

Attachments:

0001-Improve-comment-in-GetNewObjectId.patchapplication/octet-stream; name=0001-Improve-comment-in-GetNewObjectId.patchDownload+3-6
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thomas Munro (#1)
Re: A slightly misleading comment in GetNewObjectId()

Thomas Munro <thomas.munro@enterprisedb.com> writes:

That makes it sound like a mere optimisation, but since commit
8e18d04d4da user-created objects are not allowed to have OIDs below
that threshold. So I propose the attached tweak.

+1

regards, tom lane

#3Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#2)
Re: A slightly misleading comment in GetNewObjectId()

On Thu, Aug 16, 2018 at 12:47 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Thomas Munro <thomas.munro@enterprisedb.com> writes:

That makes it sound like a mere optimisation, but since commit
8e18d04d4da user-created objects are not allowed to have OIDs below
that threshold. So I propose the attached tweak.

+1

Looks good to me, too.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Shawn Debnath
sdn@amazon.com
In reply to: Robert Haas (#3)
Re: A slightly misleading comment in GetNewObjectId()

On Thu, Aug 16, 2018 at 11:36:58AM -0400, Robert Haas wrote:

On Thu, Aug 16, 2018 at 12:47 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Thomas Munro <thomas.munro@enterprisedb.com> writes:

That makes it sound like a mere optimisation, but since commit
8e18d04d4da user-created objects are not allowed to have OIDs below
that threshold. So I propose the attached tweak.

+1

Looks good to me, too.

+1 and thanks for pointing to the commit which makes this a reality.

--
Shawn Debnath