diff options
author | Noah Misch <noah@leadboat.com> | 2024-06-27 19:21:05 -0700 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2024-06-27 19:21:05 -0700 |
commit | bb93640a681c2cc709e9836e169c8f3eb556df57 (patch) | |
tree | bdd9c37008aa9d200cfbfd264ee3b24794f5aa1a /src/backend/utils/activity/wait_event_funcs.c | |
parent | 0844b3968985447ed0a6937cfc8639e379da2fe6 (diff) | |
download | postgresql-bb93640a681c2cc709e9836e169c8f3eb556df57.tar.gz postgresql-bb93640a681c2cc709e9836e169c8f3eb556df57.zip |
Add wait event type "InjectionPoint", a custom type like "Extension".
Both injection points and customization of type "Extension" are new in
v17, so this just changes a detail of an unreleased feature.
Reported by Robert Haas. Reviewed by Michael Paquier.
Discussion: https://postgr.es/m/CA+TgmobfMU5pdXP36D5iAwxV5WKE_vuDLtp_1QyH+H5jMMt21g@mail.gmail.com
Diffstat (limited to 'src/backend/utils/activity/wait_event_funcs.c')
-rw-r--r-- | src/backend/utils/activity/wait_event_funcs.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/backend/utils/activity/wait_event_funcs.c b/src/backend/utils/activity/wait_event_funcs.c index ba244c2cf36..fa8bc05c0c7 100644 --- a/src/backend/utils/activity/wait_event_funcs.c +++ b/src/backend/utils/activity/wait_event_funcs.c @@ -48,7 +48,7 @@ pg_get_wait_events(PG_FUNCTION_ARGS) #define PG_GET_WAIT_EVENTS_COLS 3 ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; char **waiteventnames; - int nbextwaitevents; + int nbwaitevents; /* Build tuplestore to hold the result rows */ InitMaterializedSRF(fcinfo, 0); @@ -67,9 +67,10 @@ pg_get_wait_events(PG_FUNCTION_ARGS) } /* Handle custom wait events for extensions */ - waiteventnames = GetWaitEventExtensionNames(&nbextwaitevents); + waiteventnames = GetWaitEventCustomNames(PG_WAIT_EXTENSION, + &nbwaitevents); - for (int idx = 0; idx < nbextwaitevents; idx++) + for (int idx = 0; idx < nbwaitevents; idx++) { StringInfoData buf; Datum values[PG_GET_WAIT_EVENTS_COLS] = {0}; @@ -89,5 +90,29 @@ pg_get_wait_events(PG_FUNCTION_ARGS) tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls); } + /* Likewise for injection points */ + waiteventnames = GetWaitEventCustomNames(PG_WAIT_INJECTIONPOINT, + &nbwaitevents); + + for (int idx = 0; idx < nbwaitevents; idx++) + { + StringInfoData buf; + Datum values[PG_GET_WAIT_EVENTS_COLS] = {0}; + bool nulls[PG_GET_WAIT_EVENTS_COLS] = {0}; + + + values[0] = CStringGetTextDatum("InjectionPoint"); + values[1] = CStringGetTextDatum(waiteventnames[idx]); + + initStringInfo(&buf); + appendStringInfo(&buf, + "Waiting for injection point \"%s\"", + waiteventnames[idx]); + + values[2] = CStringGetTextDatum(buf.data); + + tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls); + } + return (Datum) 0; } |