1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Refactor some code related to wait events "BufferPin" and "Extension"

The following changes are done:
- Addition of WaitEventBufferPin and WaitEventExtension, that hold a
list of wait events related to each category.
- Addition of two functions that encapsulate the list of wait events for
each category.
- Rename BUFFER_PIN to BUFFERPIN (only this wait event class used an
underscore, requiring a specific rule in the automation script).

These changes make a bit easier the automatic generation of all the code
and documentation related to wait events, as all the wait event
categories are now controlled by consistent structures and functions.

Author: Bertrand Drouvot
Discussion: https://postgr.es/m/c6f35117-4b20-4c78-1df5-d3056010dcf5@gmail.com
Discussion: https://postgr.es/m/77a86b3a-c4a8-5f5d-69b9-d70bbf2e9b98@gmail.com
This commit is contained in:
Michael Paquier
2023-07-03 11:01:02 +09:00
parent 8c12838001
commit 2aeaf80e57
11 changed files with 93 additions and 19 deletions

View File

@@ -28,7 +28,9 @@
static const char *pgstat_get_wait_activity(WaitEventActivity w);
static const char *pgstat_get_wait_bufferpin(WaitEventBufferPin w);
static const char *pgstat_get_wait_client(WaitEventClient w);
static const char *pgstat_get_wait_extension(WaitEventExtension w);
static const char *pgstat_get_wait_ipc(WaitEventIPC w);
static const char *pgstat_get_wait_timeout(WaitEventTimeout w);
static const char *pgstat_get_wait_io(WaitEventIO w);
@@ -90,7 +92,7 @@ pgstat_get_wait_event_type(uint32 wait_event_info)
case PG_WAIT_LOCK:
event_type = "Lock";
break;
case PG_WAIT_BUFFER_PIN:
case PG_WAIT_BUFFERPIN:
event_type = "BufferPin";
break;
case PG_WAIT_ACTIVITY:
@@ -147,9 +149,13 @@ pgstat_get_wait_event(uint32 wait_event_info)
case PG_WAIT_LOCK:
event_name = GetLockNameFromTagType(eventId);
break;
case PG_WAIT_BUFFER_PIN:
event_name = "BufferPin";
break;
case PG_WAIT_BUFFERPIN:
{
WaitEventBufferPin w = (WaitEventBufferPin) wait_event_info;
event_name = pgstat_get_wait_bufferpin(w);
break;
}
case PG_WAIT_ACTIVITY:
{
WaitEventActivity w = (WaitEventActivity) wait_event_info;
@@ -165,8 +171,12 @@ pgstat_get_wait_event(uint32 wait_event_info)
break;
}
case PG_WAIT_EXTENSION:
event_name = "Extension";
break;
{
WaitEventExtension w = (WaitEventExtension) wait_event_info;
event_name = pgstat_get_wait_extension(w);
break;
}
case PG_WAIT_IPC:
{
WaitEventIPC w = (WaitEventIPC) wait_event_info;
@@ -254,6 +264,28 @@ pgstat_get_wait_activity(WaitEventActivity w)
return event_name;
}
/* ----------
* pgstat_get_wait_bufferpin() -
*
* Convert WaitEventBufferPin to string.
* ----------
*/
static const char *
pgstat_get_wait_bufferpin(WaitEventBufferPin w)
{
const char *event_name = "unknown wait event";
switch (w)
{
case WAIT_EVENT_BUFFER_PIN:
event_name = "BufferPin";
break;
/* no default case, so that compiler will warn */
}
return event_name;
}
/* ----------
* pgstat_get_wait_client() -
*
@@ -297,6 +329,28 @@ pgstat_get_wait_client(WaitEventClient w)
return event_name;
}
/* ----------
* pgstat_get_wait_extension() -
*
* Convert WaitEventExtension to string.
* ----------
*/
static const char *
pgstat_get_wait_extension(WaitEventExtension w)
{
const char *event_name = "unknown wait event";
switch (w)
{
case WAIT_EVENT_EXTENSION:
event_name = "Extension";
break;
/* no default case, so that compiler will warn */
}
return event_name;
}
/* ----------
* pgstat_get_wait_ipc() -
*