Hi, On Sat, Apr 26, 2025 at 04:42:56PM +0900, Michael Paquier wrote: > This one is my fault,
I do feel guilty too... > 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. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
>From c6d1883b6fef09e4c3512b6f6704c1913ff719ce Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot <bertranddrouvot...@gmail.com> Date: Thu, 24 Apr 2025 17:11:03 +0000 Subject: [PATCH v2] Avoid including wait_event.h in wait_event_types.h Adding wait_classes.h to avoid including wait_event.h in wait_event_types.h (that produced a circular include). --- .../activity/generate-wait_event_types.pl | 2 +- src/include/utils/wait_classes.h | 29 +++++++++++++++++++ src/include/utils/wait_event.h | 17 ++--------- 3 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 src/include/utils/wait_classes.h diff --git a/src/backend/utils/activity/generate-wait_event_types.pl b/src/backend/utils/activity/generate-wait_event_types.pl index 171bf2ae632..424ad9f115d 100644 --- a/src/backend/utils/activity/generate-wait_event_types.pl +++ b/src/backend/utils/activity/generate-wait_event_types.pl @@ -168,7 +168,7 @@ if ($gen_code) printf $h $header_comment, 'wait_event_types.h'; printf $h "#ifndef WAIT_EVENT_TYPES_H\n"; printf $h "#define WAIT_EVENT_TYPES_H\n\n"; - printf $h "#include \"utils/wait_event.h\"\n\n"; + printf $h "#include \"utils/wait_classes.h\"\n\n"; printf $c $header_comment, 'pgstat_wait_event.c'; diff --git a/src/include/utils/wait_classes.h b/src/include/utils/wait_classes.h new file mode 100644 index 00000000000..b8e7b1f4c24 --- /dev/null +++ b/src/include/utils/wait_classes.h @@ -0,0 +1,29 @@ +/*------------------------------------------------------------------------- + * wait_classes.h + * Define the wait classes + * + * Copyright (c) 2001-2025, PostgreSQL Global Development Group + * + * src/include/utils/wait_classes.h + * ---------- + */ +#ifndef WAIT_CLASSES_H +#define WAIT_CLASSES_H + + +/* ---------- + * Wait Classes + * ---------- + */ +#define PG_WAIT_LWLOCK 0x01000000U +#define PG_WAIT_LOCK 0x03000000U +#define PG_WAIT_BUFFERPIN 0x04000000U +#define PG_WAIT_ACTIVITY 0x05000000U +#define PG_WAIT_CLIENT 0x06000000U +#define PG_WAIT_EXTENSION 0x07000000U +#define PG_WAIT_IPC 0x08000000U +#define PG_WAIT_TIMEOUT 0x09000000U +#define PG_WAIT_IO 0x0A000000U +#define PG_WAIT_INJECTIONPOINT 0x0B000000U + +#endif /* WAIT_CLASSES_H */ diff --git a/src/include/utils/wait_event.h b/src/include/utils/wait_event.h index b8cb3e5a430..7829bee5188 100644 --- a/src/include/utils/wait_event.h +++ b/src/include/utils/wait_event.h @@ -10,21 +10,8 @@ #ifndef WAIT_EVENT_H #define WAIT_EVENT_H - -/* ---------- - * Wait Classes - * ---------- - */ -#define PG_WAIT_LWLOCK 0x01000000U -#define PG_WAIT_LOCK 0x03000000U -#define PG_WAIT_BUFFERPIN 0x04000000U -#define PG_WAIT_ACTIVITY 0x05000000U -#define PG_WAIT_CLIENT 0x06000000U -#define PG_WAIT_EXTENSION 0x07000000U -#define PG_WAIT_IPC 0x08000000U -#define PG_WAIT_TIMEOUT 0x09000000U -#define PG_WAIT_IO 0x0A000000U -#define PG_WAIT_INJECTIONPOINT 0x0B000000U +/* wait classes */ +#include "utils/wait_classes.h" /* enums for wait events */ #include "utils/wait_event_types.h" -- 2.34.1