Re: Removing useless #include's.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Removing useless #include's.
Date: 2018-02-15 16:12:05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)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

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Nikolay Shaplov 2018-02-15 16:29:55 Re: [PATCH][PROPOSAL] Add enum releation option type
Previous Message Konstantin Knizhnik 2018-02-15 16:00:28 Contention preventing locking