mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
pgstat: split different types of stats into separate files.
pgstat.c is very long, and it's hard to find an order that makes sense and is likely to be maintained over time. Splitting the different pieces into separate files makes that a lot easier. With a few exceptions, this commit just moves code around. Those exceptions are: - adding file headers for new files - removing 'static' from functions - adapting pgstat_assert_is_up() to work across TUs - minor comment adjustments git diff --color-moved=dimmed-zebra is very helpful separating code movement from code changes. The next commit in this series will reorder pgstat.[ch] contents to be a bit more coherent. Earlier revisions of this patch had "global" statistics (archiver, bgwriter, checkpointer, replication slots, SLRU, WAL) in one file, because each seemed small enough. However later commits will increase their size and their aggregate size is not insubstantial. It also just seems easier to split each type of statistic into its own file. Author: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
This commit is contained in:
78
src/backend/utils/activity/pgstat_subscription.c
Normal file
78
src/backend/utils/activity/pgstat_subscription.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
*
|
||||
* pgstat_subscription.c
|
||||
* Implementation of subscription statistics.
|
||||
*
|
||||
* This file contains the implementation of subscription statistics. It is kept
|
||||
* separate from pgstat.c to enforce the line between the statistics access /
|
||||
* storage implementation and the details about individual types of
|
||||
* statistics.
|
||||
*
|
||||
* Copyright (c) 2001-2022, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* src/backend/utils/activity/pgstat_subscription.c
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "utils/pgstat_internal.h"
|
||||
|
||||
|
||||
/* ----------
|
||||
* pgstat_reset_subscription_counter() -
|
||||
*
|
||||
* Tell the statistics collector to reset a single subscription
|
||||
* counter, or all subscription counters (when subid is InvalidOid).
|
||||
*
|
||||
* Permission checking for this function is managed through the normal
|
||||
* GRANT system.
|
||||
* ----------
|
||||
*/
|
||||
void
|
||||
pgstat_reset_subscription_counter(Oid subid)
|
||||
{
|
||||
PgStat_MsgResetsubcounter msg;
|
||||
|
||||
if (pgStatSock == PGINVALID_SOCKET)
|
||||
return;
|
||||
|
||||
msg.m_subid = subid;
|
||||
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETSUBCOUNTER);
|
||||
|
||||
pgstat_send(&msg, sizeof(msg));
|
||||
}
|
||||
|
||||
/* ----------
|
||||
* pgstat_report_subscription_error() -
|
||||
*
|
||||
* Tell the collector about the subscription error.
|
||||
* ----------
|
||||
*/
|
||||
void
|
||||
pgstat_report_subscription_error(Oid subid, bool is_apply_error)
|
||||
{
|
||||
PgStat_MsgSubscriptionError msg;
|
||||
|
||||
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_SUBSCRIPTIONERROR);
|
||||
msg.m_subid = subid;
|
||||
msg.m_is_apply_error = is_apply_error;
|
||||
pgstat_send(&msg, sizeof(PgStat_MsgSubscriptionError));
|
||||
}
|
||||
|
||||
/* ----------
|
||||
* pgstat_report_subscription_drop() -
|
||||
*
|
||||
* Tell the collector about dropping the subscription.
|
||||
* ----------
|
||||
*/
|
||||
void
|
||||
pgstat_report_subscription_drop(Oid subid)
|
||||
{
|
||||
PgStat_MsgSubscriptionDrop msg;
|
||||
|
||||
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_SUBSCRIPTIONDROP);
|
||||
msg.m_subid = subid;
|
||||
pgstat_send(&msg, sizeof(PgStat_MsgSubscriptionDrop));
|
||||
}
|
||||
Reference in New Issue
Block a user