unnecessary #include "pg_getopt.h"?

Started by torikoshiaover 3 years ago4 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.

appliessuccessCI 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:t47882
psql -h localhost -U postgres

Built from patchset v1 (message #1), September 20, 2026 at 05:19 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 t47882_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 t47882_1 && git checkout t47882_1

Patchset v1 (message #1) is on t47882_1

Jump to latest
#1torikoshia
torikoshia@oss.nttdata.com

Hi,

While working on [1]/messages/by-id/d660ef741ce3d82f3b4283f1cafd576c@oss.nttdata.com -- Regards,, I thought there seems to be unnecessary #include
"pg_getopt.h".
getopt_long.h has already included pg_getopt.h, but some files include
both getopt.h and getopt_long.h.

[1]: /messages/by-id/d660ef741ce3d82f3b4283f1cafd576c@oss.nttdata.com -- Regards,
/messages/by-id/d660ef741ce3d82f3b4283f1cafd576c@oss.nttdata.com
--
Regards,

--
Atsushi Torikoshi
NTT DATA CORPORATION

Attachments:

t47882_1
v1-0001-Remove-unnecessary-inlucde-pg_getopt.patchtext/x-diff; name=v1-0001-Remove-unnecessary-inlucde-pg_getopt.patchDownload+0-6
#2Michael Paquier
michael@paquier.xyz
In reply to: torikoshia (#1)
Re: unnecessary #include "pg_getopt.h"?

On Mon, May 22, 2023 at 06:48:37PM +0900, torikoshia wrote:

While working on [1], I thought there seems to be unnecessary #include
"pg_getopt.h".
getopt_long.h has already included pg_getopt.h, but some files include both
getopt.h and getopt_long.h.

Right, these could be removed. I am not seeing other places in the
tree that include both. That's always nice to clean up.
--
Michael

#3Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#2)
Re: unnecessary #include "pg_getopt.h"?

Hi,

On 2023-05-24 09:59:18 +0900, Michael Paquier wrote:

On Mon, May 22, 2023 at 06:48:37PM +0900, torikoshia wrote:

While working on [1], I thought there seems to be unnecessary #include
"pg_getopt.h".
getopt_long.h has already included pg_getopt.h, but some files include both
getopt.h and getopt_long.h.

Right, these could be removed. I am not seeing other places in the
tree that include both. That's always nice to clean up.

This feels more like a matter of taste to me than anything. At least some of
the files touched in the patch use optarg, opterr etc. - which are declared in
pg_getopt.h. Making it reasonable to directly include pg_getopt.h.

I don't really see a need to change anything here?

Greetings,

Andres Freund

#4Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#3)
Re: unnecessary #include "pg_getopt.h"?

On Tue, May 23, 2023 at 06:37:59PM -0700, Andres Freund wrote:

This feels more like a matter of taste to me than anything.

Yup, it is.

At least some of
the files touched in the patch use optarg, opterr etc. - which are declared in
pg_getopt.h. Making it reasonable to directly include pg_getopt.h.

getopt_long.h is included in 21 places of src/bin/, with all of them
touching optarg, while only four of them include pg_getopt.h. So
removing them as suggested makes sense. I agree with the tasting
matter as well, still there is also a consistency matter.
--
Michael