Re: Avoid circular header file dependency

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-04-28T00:12:30Z
Lists: pgsql-hackers
On Sat, Apr 26, 2025 at 08:31:32AM +0000, Bertrand Drouvot wrote:
> On Sat, Apr 26, 2025 at 04:42:56PM +0900, Michael Paquier wrote:
>> Splitting the values
>> of the wait classes into their own header makes sense, but the header
>> name wait_class_constants.h sounds a bit off.  Why not a simpler
>> "wait_classes.h" that gets included by wait_event.h and
>> wait_event_types.h?
> 
> Yeah, better. Done that way in the attached.

--- a/src/include/utils/wait_event.h
+++ b/src/include/utils/wait_event.h
@@ -10,21 +10,8 @@
[...]
+/* wait classes  */
+#include "utils/wait_classes.h"

This part is not required.  wait_event.h can survive the day even if
it does not know about that.

Note that it is true that wait_event.h could also work without
wait_event_types.h, but it is more useful to keep it in wait_event.h
as all the other code paths in need of the pgstat_report_* calls want
to know about the wait event enums.

I've reproduced your original report with clang-tidy on my end,
removed the include that was not required in wait_event.h, fixed one
comment, cross-checked that the result actually works, and applied the
result.  Thanks for the report!
--
Michael

Commits

  1. Remove circular #include's between wait_event.h and wait_event_types.h

  2. Remove circular #include's between plpython.h and plpy_util.h.