Re: Avoid circular header file dependency

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid circular header file dependency
Date: 2025-04-28 00:12:30
Message-ID: aA7H7rDlqxBiQc2k@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-04-28 02:38:00 Re: DOCS - create publication (tweak for generated columns)
Previous Message Hannu Krosing 2025-04-27 23:55:31 Re: RFC: Logging plan of the running query