pgstat: normalize function naming.
Most of pgstat uses pgstat_<verb>_<subject>() or just <verb>_<subject>(). But not all (some introduced fairly recently by me). Rename ones that aren't intentionally following a different scheme (e.g. AtEOXact_*).
This commit is contained in:
parent
79b716cfb7
commit
be902e2651
@ -73,7 +73,7 @@ relation_open(Oid relationId, LOCKMODE lockmode)
|
||||
if (RelationUsesLocalBuffers(r))
|
||||
MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPNAMESPACE;
|
||||
|
||||
pgstat_relation_init(r);
|
||||
pgstat_init_relation(r);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -123,7 +123,7 @@ try_relation_open(Oid relationId, LOCKMODE lockmode)
|
||||
if (RelationUsesLocalBuffers(r))
|
||||
MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPNAMESPACE;
|
||||
|
||||
pgstat_relation_init(r);
|
||||
pgstat_init_relation(r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
|
||||
|
||||
/* shared->latest_page_number will be set later */
|
||||
|
||||
shared->slru_stats_idx = pgstat_slru_index(name);
|
||||
shared->slru_stats_idx = pgstat_get_slru_index(name);
|
||||
|
||||
ptr = (char *) shared;
|
||||
offset = MAXALIGN(sizeof(SlruSharedData));
|
||||
|
@ -727,7 +727,7 @@ pgstat_initialize(void)
|
||||
{
|
||||
Assert(!pgstat_is_initialized);
|
||||
|
||||
pgstat_wal_initialize();
|
||||
pgstat_init_wal();
|
||||
|
||||
/* Set up a process-exit hook to clean up */
|
||||
before_shmem_exit(pgstat_shutdown_hook, 0);
|
||||
@ -768,7 +768,7 @@ pgstat_report_stat(bool disconnect)
|
||||
*/
|
||||
if (!have_relation_stats &&
|
||||
pgStatXactCommit == 0 && pgStatXactRollback == 0 &&
|
||||
!pgstat_wal_pending() &&
|
||||
!pgstat_have_pending_wal() &&
|
||||
!have_function_stats && !disconnect)
|
||||
return;
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* for the life of the backend. Also, we zero out the t_id fields of the
|
||||
* contained PgStat_TableStatus structs whenever they are not actively in use.
|
||||
* This allows relcache pgstat_info pointers to be treated as long-lived data,
|
||||
* avoiding repeated searches in pgstat_relation_init() when a relation is
|
||||
* avoiding repeated searches in pgstat_init_relation() when a relation is
|
||||
* repeatedly opened during a transaction.
|
||||
*/
|
||||
#define TABSTAT_QUANTUM 100 /* we alloc this many at a time */
|
||||
@ -78,8 +78,8 @@ static PgStat_TableStatus *get_tabstat_entry(Oid rel_id, bool isshared);
|
||||
static void pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg, TimestampTz now);
|
||||
static void add_tabstat_xact_level(PgStat_TableStatus *pgstat_info, int nest_level);
|
||||
static void ensure_tabstat_xact_level(PgStat_TableStatus *pgstat_info);
|
||||
static void pgstat_truncdrop_save_counters(PgStat_TableXactStatus *trans, bool is_drop);
|
||||
static void pgstat_truncdrop_restore_counters(PgStat_TableXactStatus *trans);
|
||||
static void save_truncdrop_counters(PgStat_TableXactStatus *trans, bool is_drop);
|
||||
static void restore_truncdrop_counters(PgStat_TableXactStatus *trans);
|
||||
|
||||
|
||||
/*
|
||||
@ -109,7 +109,7 @@ pgstat_copy_relation_stats(Relation dst, Relation src)
|
||||
if (!srcstats)
|
||||
return;
|
||||
|
||||
if (pgstat_relation_should_count(dst))
|
||||
if (pgstat_should_count_relation(dst))
|
||||
{
|
||||
/*
|
||||
* XXX: temporarily this does not actually quite do what the name
|
||||
@ -137,7 +137,7 @@ pgstat_copy_relation_stats(Relation dst, Relation src)
|
||||
* same relation is touched repeatedly within a transaction.
|
||||
*/
|
||||
void
|
||||
pgstat_relation_init(Relation rel)
|
||||
pgstat_init_relation(Relation rel)
|
||||
{
|
||||
Oid rel_id = rel->rd_id;
|
||||
char relkind = rel->rd_rel->relkind;
|
||||
@ -242,7 +242,7 @@ pgstat_report_analyze(Relation rel,
|
||||
*
|
||||
* Waste no time on partitioned tables, though.
|
||||
*/
|
||||
if (pgstat_relation_should_count(rel) &&
|
||||
if (pgstat_should_count_relation(rel) &&
|
||||
rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
|
||||
{
|
||||
PgStat_TableXactStatus *trans;
|
||||
@ -276,7 +276,7 @@ pgstat_report_analyze(Relation rel,
|
||||
void
|
||||
pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
|
||||
{
|
||||
if (pgstat_relation_should_count(rel))
|
||||
if (pgstat_should_count_relation(rel))
|
||||
{
|
||||
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
|
||||
|
||||
@ -291,7 +291,7 @@ pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
|
||||
void
|
||||
pgstat_count_heap_update(Relation rel, bool hot)
|
||||
{
|
||||
if (pgstat_relation_should_count(rel))
|
||||
if (pgstat_should_count_relation(rel))
|
||||
{
|
||||
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
|
||||
|
||||
@ -310,7 +310,7 @@ pgstat_count_heap_update(Relation rel, bool hot)
|
||||
void
|
||||
pgstat_count_heap_delete(Relation rel)
|
||||
{
|
||||
if (pgstat_relation_should_count(rel))
|
||||
if (pgstat_should_count_relation(rel))
|
||||
{
|
||||
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
|
||||
|
||||
@ -325,12 +325,12 @@ pgstat_count_heap_delete(Relation rel)
|
||||
void
|
||||
pgstat_count_truncate(Relation rel)
|
||||
{
|
||||
if (pgstat_relation_should_count(rel))
|
||||
if (pgstat_should_count_relation(rel))
|
||||
{
|
||||
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
|
||||
|
||||
ensure_tabstat_xact_level(pgstat_info);
|
||||
pgstat_truncdrop_save_counters(pgstat_info->trans, false);
|
||||
save_truncdrop_counters(pgstat_info->trans, false);
|
||||
pgstat_info->trans->tuples_inserted = 0;
|
||||
pgstat_info->trans->tuples_updated = 0;
|
||||
pgstat_info->trans->tuples_deleted = 0;
|
||||
@ -348,7 +348,7 @@ pgstat_count_truncate(Relation rel)
|
||||
void
|
||||
pgstat_update_heap_dead_tuples(Relation rel, int delta)
|
||||
{
|
||||
if (pgstat_relation_should_count(rel))
|
||||
if (pgstat_should_count_relation(rel))
|
||||
{
|
||||
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
|
||||
|
||||
@ -405,7 +405,7 @@ AtEOXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit)
|
||||
Assert(tabstat->trans == trans);
|
||||
/* restore pre-truncate/drop stats (if any) in case of aborted xact */
|
||||
if (!isCommit)
|
||||
pgstat_truncdrop_restore_counters(trans);
|
||||
restore_truncdrop_counters(trans);
|
||||
/* count attempted actions regardless of commit/abort */
|
||||
tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
|
||||
tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
|
||||
@ -470,7 +470,7 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
|
||||
if (trans->truncdropped)
|
||||
{
|
||||
/* propagate the truncate/drop status one level up */
|
||||
pgstat_truncdrop_save_counters(trans->upper, false);
|
||||
save_truncdrop_counters(trans->upper, false);
|
||||
/* replace upper xact stats with ours */
|
||||
trans->upper->tuples_inserted = trans->tuples_inserted;
|
||||
trans->upper->tuples_updated = trans->tuples_updated;
|
||||
@ -497,7 +497,7 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
|
||||
*/
|
||||
PgStat_SubXactStatus *upper_xact_state;
|
||||
|
||||
upper_xact_state = pgstat_xact_stack_level_get(nestDepth - 1);
|
||||
upper_xact_state = pgstat_get_xact_stack_level(nestDepth - 1);
|
||||
trans->next = upper_xact_state->first;
|
||||
upper_xact_state->first = trans;
|
||||
trans->nest_level = nestDepth - 1;
|
||||
@ -511,7 +511,7 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
|
||||
*/
|
||||
|
||||
/* first restore values obliterated by truncate/drop */
|
||||
pgstat_truncdrop_restore_counters(trans);
|
||||
restore_truncdrop_counters(trans);
|
||||
/* count attempted actions regardless of commit/abort */
|
||||
tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
|
||||
tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
|
||||
@ -860,7 +860,7 @@ add_tabstat_xact_level(PgStat_TableStatus *pgstat_info, int nest_level)
|
||||
* If this is the first rel to be modified at the current nest level, we
|
||||
* first have to push a transaction stack entry.
|
||||
*/
|
||||
xact_state = pgstat_xact_stack_level_get(nest_level);
|
||||
xact_state = pgstat_get_xact_stack_level(nest_level);
|
||||
|
||||
/* Now make a per-table stack entry */
|
||||
trans = (PgStat_TableXactStatus *)
|
||||
@ -897,7 +897,7 @@ ensure_tabstat_xact_level(PgStat_TableStatus *pgstat_info)
|
||||
* subxact level only.
|
||||
*/
|
||||
static void
|
||||
pgstat_truncdrop_save_counters(PgStat_TableXactStatus *trans, bool is_drop)
|
||||
save_truncdrop_counters(PgStat_TableXactStatus *trans, bool is_drop)
|
||||
{
|
||||
if (!trans->truncdropped || is_drop)
|
||||
{
|
||||
@ -912,7 +912,7 @@ pgstat_truncdrop_save_counters(PgStat_TableXactStatus *trans, bool is_drop)
|
||||
* restore counters when a truncate aborts
|
||||
*/
|
||||
static void
|
||||
pgstat_truncdrop_restore_counters(PgStat_TableXactStatus *trans)
|
||||
restore_truncdrop_counters(PgStat_TableXactStatus *trans)
|
||||
{
|
||||
if (trans->truncdropped)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "utils/pgstat_internal.h"
|
||||
|
||||
|
||||
static inline PgStat_MsgSLRU *slru_entry(int slru_idx);
|
||||
static inline PgStat_MsgSLRU *get_slru_entry(int slru_idx);
|
||||
|
||||
|
||||
/*
|
||||
@ -49,7 +49,7 @@ pgstat_reset_slru(const char *name)
|
||||
return;
|
||||
|
||||
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETSLRUCOUNTER);
|
||||
msg.m_index = pgstat_slru_index(name);
|
||||
msg.m_index = pgstat_get_slru_index(name);
|
||||
|
||||
pgstat_send(&msg, sizeof(msg));
|
||||
}
|
||||
@ -61,43 +61,43 @@ pgstat_reset_slru(const char *name)
|
||||
void
|
||||
pgstat_count_slru_page_zeroed(int slru_idx)
|
||||
{
|
||||
slru_entry(slru_idx)->m_blocks_zeroed += 1;
|
||||
get_slru_entry(slru_idx)->m_blocks_zeroed += 1;
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_hit(int slru_idx)
|
||||
{
|
||||
slru_entry(slru_idx)->m_blocks_hit += 1;
|
||||
get_slru_entry(slru_idx)->m_blocks_hit += 1;
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_exists(int slru_idx)
|
||||
{
|
||||
slru_entry(slru_idx)->m_blocks_exists += 1;
|
||||
get_slru_entry(slru_idx)->m_blocks_exists += 1;
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_read(int slru_idx)
|
||||
{
|
||||
slru_entry(slru_idx)->m_blocks_read += 1;
|
||||
get_slru_entry(slru_idx)->m_blocks_read += 1;
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_count_slru_page_written(int slru_idx)
|
||||
{
|
||||
slru_entry(slru_idx)->m_blocks_written += 1;
|
||||
get_slru_entry(slru_idx)->m_blocks_written += 1;
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_count_slru_flush(int slru_idx)
|
||||
{
|
||||
slru_entry(slru_idx)->m_flush += 1;
|
||||
get_slru_entry(slru_idx)->m_flush += 1;
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_count_slru_truncate(int slru_idx)
|
||||
{
|
||||
slru_entry(slru_idx)->m_truncate += 1;
|
||||
get_slru_entry(slru_idx)->m_truncate += 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -106,7 +106,7 @@ pgstat_count_slru_truncate(int slru_idx)
|
||||
* know the number of entries in advance.
|
||||
*/
|
||||
const char *
|
||||
pgstat_slru_name(int slru_idx)
|
||||
pgstat_get_slru_name(int slru_idx)
|
||||
{
|
||||
if (slru_idx < 0 || slru_idx >= SLRU_NUM_ELEMENTS)
|
||||
return NULL;
|
||||
@ -120,7 +120,7 @@ pgstat_slru_name(int slru_idx)
|
||||
* external projects.
|
||||
*/
|
||||
int
|
||||
pgstat_slru_index(const char *name)
|
||||
pgstat_get_slru_index(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -174,7 +174,7 @@ pgstat_send_slru(void)
|
||||
* stored in SlruCtl as lwlock tranche name).
|
||||
*/
|
||||
static inline PgStat_MsgSLRU *
|
||||
slru_entry(int slru_idx)
|
||||
get_slru_entry(int slru_idx)
|
||||
{
|
||||
pgstat_assert_is_up();
|
||||
|
||||
|
@ -130,7 +130,7 @@ pgstat_report_wal(bool force)
|
||||
}
|
||||
|
||||
void
|
||||
pgstat_wal_initialize(void)
|
||||
pgstat_init_wal(void)
|
||||
{
|
||||
/*
|
||||
* Initialize prevWalUsage with pgWalUsage so that pgstat_report_wal() can
|
||||
@ -148,7 +148,7 @@ pgstat_wal_initialize(void)
|
||||
* data pages.
|
||||
*/
|
||||
bool
|
||||
pgstat_wal_pending(void)
|
||||
pgstat_have_pending_wal(void)
|
||||
{
|
||||
return pgWalUsage.wal_records != prevWalUsage.wal_records ||
|
||||
WalStats.m_wal_write != 0 ||
|
||||
|
@ -139,7 +139,7 @@ AtEOSubXact_PgStat_DroppedStats(PgStat_SubXactStatus *xact_state,
|
||||
if (xact_state->pending_drops_count == 0)
|
||||
return;
|
||||
|
||||
parent_xact_state = pgstat_xact_stack_level_get(nestDepth - 1);
|
||||
parent_xact_state = pgstat_get_xact_stack_level(nestDepth - 1);
|
||||
|
||||
dlist_foreach_modify(iter, &xact_state->pending_drops)
|
||||
{
|
||||
@ -228,7 +228,7 @@ PostPrepare_PgStat(void)
|
||||
* it if needed.
|
||||
*/
|
||||
PgStat_SubXactStatus *
|
||||
pgstat_xact_stack_level_get(int nest_level)
|
||||
pgstat_get_xact_stack_level(int nest_level)
|
||||
{
|
||||
PgStat_SubXactStatus *xact_state;
|
||||
|
||||
@ -324,7 +324,7 @@ create_drop_transactional_internal(PgStat_Kind kind, Oid dboid, Oid objoid, bool
|
||||
PgStat_PendingDroppedStatsItem *drop = (PgStat_PendingDroppedStatsItem *)
|
||||
MemoryContextAlloc(TopTransactionContext, sizeof(PgStat_PendingDroppedStatsItem));
|
||||
|
||||
xact_state = pgstat_xact_stack_level_get(nest_level);
|
||||
xact_state = pgstat_get_xact_stack_level(nest_level);
|
||||
|
||||
drop->is_create = is_create;
|
||||
drop->item.kind = kind;
|
||||
|
@ -1830,7 +1830,7 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
|
||||
PgStat_SLRUStats stat;
|
||||
const char *name;
|
||||
|
||||
name = pgstat_slru_name(i);
|
||||
name = pgstat_get_slru_name(i);
|
||||
|
||||
if (!name)
|
||||
break;
|
||||
|
@ -1069,7 +1069,7 @@ extern void pgstat_create_relation(Relation rel);
|
||||
extern void pgstat_drop_relation(Relation rel);
|
||||
extern void pgstat_copy_relation_stats(Relation dstrel, Relation srcrel);
|
||||
|
||||
extern void pgstat_relation_init(Relation rel);
|
||||
extern void pgstat_init_relation(Relation rel);
|
||||
|
||||
extern void pgstat_report_vacuum(Oid tableoid, bool shared,
|
||||
PgStat_Counter livetuples, PgStat_Counter deadtuples);
|
||||
@ -1077,44 +1077,44 @@ extern void pgstat_report_analyze(Relation rel,
|
||||
PgStat_Counter livetuples, PgStat_Counter deadtuples,
|
||||
bool resetcounter);
|
||||
|
||||
#define pgstat_relation_should_count(rel) \
|
||||
#define pgstat_should_count_relation(rel) \
|
||||
(likely((rel)->pgstat_info != NULL))
|
||||
|
||||
/* nontransactional event counts are simple enough to inline */
|
||||
|
||||
#define pgstat_count_heap_scan(rel) \
|
||||
do { \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
if (pgstat_should_count_relation(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_numscans++; \
|
||||
} while (0)
|
||||
#define pgstat_count_heap_getnext(rel) \
|
||||
do { \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
if (pgstat_should_count_relation(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_tuples_returned++; \
|
||||
} while (0)
|
||||
#define pgstat_count_heap_fetch(rel) \
|
||||
do { \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
if (pgstat_should_count_relation(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_tuples_fetched++; \
|
||||
} while (0)
|
||||
#define pgstat_count_index_scan(rel) \
|
||||
do { \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
if (pgstat_should_count_relation(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_numscans++; \
|
||||
} while (0)
|
||||
#define pgstat_count_index_tuples(rel, n) \
|
||||
do { \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
if (pgstat_should_count_relation(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
|
||||
} while (0)
|
||||
#define pgstat_count_buffer_read(rel) \
|
||||
do { \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
if (pgstat_should_count_relation(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_blocks_fetched++; \
|
||||
} while (0)
|
||||
#define pgstat_count_buffer_hit(rel) \
|
||||
do { \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
if (pgstat_should_count_relation(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_blocks_hit++; \
|
||||
} while (0)
|
||||
|
||||
@ -1155,8 +1155,8 @@ extern void pgstat_count_slru_page_written(int slru_idx);
|
||||
extern void pgstat_count_slru_page_exists(int slru_idx);
|
||||
extern void pgstat_count_slru_flush(int slru_idx);
|
||||
extern void pgstat_count_slru_truncate(int slru_idx);
|
||||
extern const char *pgstat_slru_name(int slru_idx);
|
||||
extern int pgstat_slru_index(const char *name);
|
||||
extern const char *pgstat_get_slru_name(int slru_idx);
|
||||
extern int pgstat_get_slru_index(const char *name);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -134,20 +134,19 @@ extern void pgstat_send_slru(void);
|
||||
* Functions in pgstat_wal.c
|
||||
*/
|
||||
|
||||
extern void pgstat_wal_initialize(void);
|
||||
extern bool pgstat_wal_pending(void);
|
||||
extern void pgstat_init_wal(void);
|
||||
extern bool pgstat_have_pending_wal(void);
|
||||
|
||||
|
||||
/*
|
||||
* Functions in pgstat_xact.c
|
||||
*/
|
||||
|
||||
extern PgStat_SubXactStatus *pgstat_xact_stack_level_get(int nest_level);
|
||||
extern PgStat_SubXactStatus *pgstat_get_xact_stack_level(int nest_level);
|
||||
extern void pgstat_drop_transactional(PgStat_Kind kind, Oid dboid, Oid objoid);
|
||||
extern void pgstat_create_transactional(PgStat_Kind kind, Oid dboid, Oid objoid);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Variables in pgstat.c
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user