many copies of atooid() and oid_cmp()

Started by Peter Eisentrautover 9 years ago8 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t35848
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 28, 2026 at 08:39 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t35848_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t35848_1 && git checkout t35848_1

Patchset v1 (message #1) is on t35848_1

Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

There are approximately 11 copies of atooid() and 3 of oid_cmp() or
equivalent, and pending patches are proposing to add more. I propose
these two patches to collect them in central places.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

t35848_1
0001-Move-atooid-definition-to-a-central-place.patchtext/x-patch; name=0001-Move-atooid-definition-to-a-central-place.patchDownload+4-24
0002-Collect-duplicate-copies-of-oid_cmp.patchtext/x-patch; name=0002-Collect-duplicate-copies-of-oid_cmp.patchDownload+17-52
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: many copies of atooid() and oid_cmp()

Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:

There are approximately 11 copies of atooid() and 3 of oid_cmp() or
equivalent, and pending patches are proposing to add more. I propose
these two patches to collect them in central places.

+1 for the concept, but I'm a bit worried about putting atooid() in
postgres_ext.h. That's going to impose on the namespace of libpq-using
applications, for instance. A more conservative answer would be to
add it to c.h. OTOH, postgres_ext.h is where the Oid typedef lives,
so I do see the consistency of adding this there. Hard choice.

The oid_cmp() move looks fine if we only need it on the server side.
But doesn't pg_dump have one too?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Kuntal Ghosh
kuntalghosh.2007@gmail.com
In reply to: Peter Eisentraut (#1)
Re: many copies of atooid() and oid_cmp()

On Wed, Jan 11, 2017 at 9:42 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

There are approximately 11 copies of atooid() and 3 of oid_cmp() or
equivalent, and pending patches are proposing to add more. I propose
these two patches to collect them in central places.

I've verified that the patch covers all the copies of atooid() and
oid_cmp() that should be replaced. However, as Tom suggested, I've
looked into pg_dump and found that there is a oidcmp() as well. It may
have been missed because it has a different name.

I was wondering whether it is worth to replace the following as well:
(TransactionId)strtoul(str, NULL, 16) to something like #define atotranid().

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#2)
Re: many copies of atooid() and oid_cmp()

On 1/11/17 11:25 PM, Tom Lane wrote:

Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:

There are approximately 11 copies of atooid() and 3 of oid_cmp() or
equivalent, and pending patches are proposing to add more. I propose
these two patches to collect them in central places.

+1 for the concept, but I'm a bit worried about putting atooid() in
postgres_ext.h. That's going to impose on the namespace of libpq-using
applications, for instance. A more conservative answer would be to
add it to c.h. OTOH, postgres_ext.h is where the Oid typedef lives,
so I do see the consistency of adding this there. Hard choice.

How about two copies: one in postgres_fe.h and one in postgres.h?

The oid_cmp() move looks fine if we only need it on the server side.
But doesn't pg_dump have one too?

The pg_dump one isn't a qsort comparator, though.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Kuntal Ghosh (#3)
Re: many copies of atooid() and oid_cmp()

On 1/12/17 12:25 AM, Kuntal Ghosh wrote:

On Wed, Jan 11, 2017 at 9:42 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

There are approximately 11 copies of atooid() and 3 of oid_cmp() or
equivalent, and pending patches are proposing to add more. I propose
these two patches to collect them in central places.

I've verified that the patch covers all the copies of atooid() and
oid_cmp() that should be replaced. However, as Tom suggested, I've
looked into pg_dump and found that there is a oidcmp() as well. It may
have been missed because it has a different name.

I was wondering whether it is worth to replace the following as well:
(TransactionId)strtoul(str, NULL, 16) to something like #define atotranid().

There is a atoxid(), which is actually not used and removed by my patch.
There are a few other calls of this pattern, but they are not frequent
or consistent enough to worry about (yet), I think.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#4)
Re: many copies of atooid() and oid_cmp()

Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:

On 1/11/17 11:25 PM, Tom Lane wrote:

+1 for the concept, but I'm a bit worried about putting atooid() in
postgres_ext.h. That's going to impose on the namespace of libpq-using
applications, for instance. A more conservative answer would be to
add it to c.h. OTOH, postgres_ext.h is where the Oid typedef lives,
so I do see the consistency of adding this there. Hard choice.

How about two copies: one in postgres_fe.h and one in postgres.h?

That seems uglier than either of the other choices.

I don't personally have a huge problem with adding atooid in
postgres_ext.h, but I thought I'd better flag the potential issue
to see if anyone else thinks it's a big problem.

The oid_cmp() move looks fine if we only need it on the server side.
But doesn't pg_dump have one too?

The pg_dump one isn't a qsort comparator, though.

OK.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#6)
Re: many copies of atooid() and oid_cmp()

On Thu, Jan 12, 2017 at 11:36 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:

On 1/11/17 11:25 PM, Tom Lane wrote:

+1 for the concept, but I'm a bit worried about putting atooid() in
postgres_ext.h. That's going to impose on the namespace of libpq-using
applications, for instance. A more conservative answer would be to
add it to c.h. OTOH, postgres_ext.h is where the Oid typedef lives,
so I do see the consistency of adding this there. Hard choice.

How about two copies: one in postgres_fe.h and one in postgres.h?

That seems uglier than either of the other choices.

I don't personally have a huge problem with adding atooid in
postgres_ext.h, but I thought I'd better flag the potential issue
to see if anyone else thinks it's a big problem.

FWIW, postgres_ext.h would make the most sense to me. Now, there is
one way to not impose that to frontends linked to libpq which would be
to locate it in some new header in src/include/common/, where both
backend and frontend could reference to it.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#8Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#6)
Re: many copies of atooid() and oid_cmp()

On 1/12/17 09:36, Tom Lane wrote:

Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:

On 1/11/17 11:25 PM, Tom Lane wrote:

+1 for the concept, but I'm a bit worried about putting atooid() in
postgres_ext.h. That's going to impose on the namespace of libpq-using
applications, for instance. A more conservative answer would be to
add it to c.h. OTOH, postgres_ext.h is where the Oid typedef lives,
so I do see the consistency of adding this there. Hard choice.

How about two copies: one in postgres_fe.h and one in postgres.h?

That seems uglier than either of the other choices.

I don't personally have a huge problem with adding atooid in
postgres_ext.h, but I thought I'd better flag the potential issue
to see if anyone else thinks it's a big problem.

committed as is then

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers