Re: Removing useless #include's. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Removing useless #include's.
Date
Msg-id 6748.1518711125@sss.pgh.pa.us
Whole thread Raw
In response to Removing useless #include's.  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Responses Re: Removing useless #include's.
List pgsql-hackers
Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> writes:
> While looking some patch, just from curiosity, I checked for
> redundant #include's in the source tree (except
> contrib). "redundant" here means that a file is included in
> another include file nearby.

> I found 641 includes that is just removable with no side effect
> with two exceptions.

I tend to be a bit suspicious of this sort of thing, especially for
old files that have been through previous rounds of "unnecessary
include" removal.  It's usually a good idea to ask *why* is a header
no longer needed?  The answer, usually, is that somebody added the
same #include to some other header, and it's not uncommon for that
to have been a bad idea.  It's usually best to minimize cross-header
inclusions, IMV, and it's always necessary to exercise judgment
when adding one.

We've also had more than a few problems with automatic scripts deciding
that an #include could be removed because they weren't testing with the
combination of build options that made it necessary.

See for instance commits 6416a82a6 through 1609797c2 for some history
of poorly managed #include removal.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Konstantin Knizhnik
Date:
Subject: Contention preventing locking
Next
From: Nikolay Shaplov
Date:
Subject: Re: [PATCH][PROPOSAL] Add enum releation option type