Skip to content

Commit be902e2

Browse files
committed
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_*).
1 parent 79b716c commit be902e2

File tree

10 files changed

+56
-57
lines changed

10 files changed

+56
-57
lines changed

src/backend/access/common/relation.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ relation_open(Oid relationId, LOCKMODE lockmode)
7373
if (RelationUsesLocalBuffers(r))
7474
MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPNAMESPACE;
7575

76-
pgstat_relation_init(r);
76+
pgstat_init_relation(r);
7777

7878
return r;
7979
}
@@ -123,7 +123,7 @@ try_relation_open(Oid relationId, LOCKMODE lockmode)
123123
if (RelationUsesLocalBuffers(r))
124124
MyXactFlags |= XACT_FLAGS_ACCESSEDTEMPNAMESPACE;
125125

126-
pgstat_relation_init(r);
126+
pgstat_init_relation(r);
127127

128128
return r;
129129
}

src/backend/access/transam/slru.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
215215

216216
/* shared->latest_page_number will be set later */
217217

218-
shared->slru_stats_idx = pgstat_slru_index(name);
218+
shared->slru_stats_idx = pgstat_get_slru_index(name);
219219

220220
ptr = (char *) shared;
221221
offset = MAXALIGN(sizeof(SlruSharedData));

src/backend/postmaster/pgstat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ pgstat_initialize(void)
727727
{
728728
Assert(!pgstat_is_initialized);
729729

730-
pgstat_wal_initialize();
730+
pgstat_init_wal();
731731

732732
/* Set up a process-exit hook to clean up */
733733
before_shmem_exit(pgstat_shutdown_hook, 0);
@@ -768,7 +768,7 @@ pgstat_report_stat(bool disconnect)
768768
*/
769769
if (!have_relation_stats &&
770770
pgStatXactCommit == 0 && pgStatXactRollback == 0 &&
771-
!pgstat_wal_pending() &&
771+
!pgstat_have_pending_wal() &&
772772
!have_function_stats && !disconnect)
773773
return;
774774

src/backend/utils/activity/pgstat_relation.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* for the life of the backend. Also, we zero out the t_id fields of the
3535
* contained PgStat_TableStatus structs whenever they are not actively in use.
3636
* This allows relcache pgstat_info pointers to be treated as long-lived data,
37-
* avoiding repeated searches in pgstat_relation_init() when a relation is
37+
* avoiding repeated searches in pgstat_init_relation() when a relation is
3838
* repeatedly opened during a transaction.
3939
*/
4040
#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);
7878
static void pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg, TimestampTz now);
7979
static void add_tabstat_xact_level(PgStat_TableStatus *pgstat_info, int nest_level);
8080
static void ensure_tabstat_xact_level(PgStat_TableStatus *pgstat_info);
81-
static void pgstat_truncdrop_save_counters(PgStat_TableXactStatus *trans, bool is_drop);
82-
static void pgstat_truncdrop_restore_counters(PgStat_TableXactStatus *trans);
81+
static void save_truncdrop_counters(PgStat_TableXactStatus *trans, bool is_drop);
82+
static void restore_truncdrop_counters(PgStat_TableXactStatus *trans);
8383

8484

8585
/*
@@ -109,7 +109,7 @@ pgstat_copy_relation_stats(Relation dst, Relation src)
109109
if (!srcstats)
110110
return;
111111

112-
if (pgstat_relation_should_count(dst))
112+
if (pgstat_should_count_relation(dst))
113113
{
114114
/*
115115
* XXX: temporarily this does not actually quite do what the name
@@ -137,7 +137,7 @@ pgstat_copy_relation_stats(Relation dst, Relation src)
137137
* same relation is touched repeatedly within a transaction.
138138
*/
139139
void
140-
pgstat_relation_init(Relation rel)
140+
pgstat_init_relation(Relation rel)
141141
{
142142
Oid rel_id = rel->rd_id;
143143
char relkind = rel->rd_rel->relkind;
@@ -242,7 +242,7 @@ pgstat_report_analyze(Relation rel,
242242
*
243243
* Waste no time on partitioned tables, though.
244244
*/
245-
if (pgstat_relation_should_count(rel) &&
245+
if (pgstat_should_count_relation(rel) &&
246246
rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
247247
{
248248
PgStat_TableXactStatus *trans;
@@ -276,7 +276,7 @@ pgstat_report_analyze(Relation rel,
276276
void
277277
pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
278278
{
279-
if (pgstat_relation_should_count(rel))
279+
if (pgstat_should_count_relation(rel))
280280
{
281281
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
282282

@@ -291,7 +291,7 @@ pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
291291
void
292292
pgstat_count_heap_update(Relation rel, bool hot)
293293
{
294-
if (pgstat_relation_should_count(rel))
294+
if (pgstat_should_count_relation(rel))
295295
{
296296
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
297297

@@ -310,7 +310,7 @@ pgstat_count_heap_update(Relation rel, bool hot)
310310
void
311311
pgstat_count_heap_delete(Relation rel)
312312
{
313-
if (pgstat_relation_should_count(rel))
313+
if (pgstat_should_count_relation(rel))
314314
{
315315
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
316316

@@ -325,12 +325,12 @@ pgstat_count_heap_delete(Relation rel)
325325
void
326326
pgstat_count_truncate(Relation rel)
327327
{
328-
if (pgstat_relation_should_count(rel))
328+
if (pgstat_should_count_relation(rel))
329329
{
330330
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
331331

332332
ensure_tabstat_xact_level(pgstat_info);
333-
pgstat_truncdrop_save_counters(pgstat_info->trans, false);
333+
save_truncdrop_counters(pgstat_info->trans, false);
334334
pgstat_info->trans->tuples_inserted = 0;
335335
pgstat_info->trans->tuples_updated = 0;
336336
pgstat_info->trans->tuples_deleted = 0;
@@ -348,7 +348,7 @@ pgstat_count_truncate(Relation rel)
348348
void
349349
pgstat_update_heap_dead_tuples(Relation rel, int delta)
350350
{
351-
if (pgstat_relation_should_count(rel))
351+
if (pgstat_should_count_relation(rel))
352352
{
353353
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
354354

@@ -405,7 +405,7 @@ AtEOXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit)
405405
Assert(tabstat->trans == trans);
406406
/* restore pre-truncate/drop stats (if any) in case of aborted xact */
407407
if (!isCommit)
408-
pgstat_truncdrop_restore_counters(trans);
408+
restore_truncdrop_counters(trans);
409409
/* count attempted actions regardless of commit/abort */
410410
tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
411411
tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
@@ -470,7 +470,7 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
470470
if (trans->truncdropped)
471471
{
472472
/* propagate the truncate/drop status one level up */
473-
pgstat_truncdrop_save_counters(trans->upper, false);
473+
save_truncdrop_counters(trans->upper, false);
474474
/* replace upper xact stats with ours */
475475
trans->upper->tuples_inserted = trans->tuples_inserted;
476476
trans->upper->tuples_updated = trans->tuples_updated;
@@ -497,7 +497,7 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
497497
*/
498498
PgStat_SubXactStatus *upper_xact_state;
499499

500-
upper_xact_state = pgstat_xact_stack_level_get(nestDepth - 1);
500+
upper_xact_state = pgstat_get_xact_stack_level(nestDepth - 1);
501501
trans->next = upper_xact_state->first;
502502
upper_xact_state->first = trans;
503503
trans->nest_level = nestDepth - 1;
@@ -511,7 +511,7 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
511511
*/
512512

513513
/* first restore values obliterated by truncate/drop */
514-
pgstat_truncdrop_restore_counters(trans);
514+
restore_truncdrop_counters(trans);
515515
/* count attempted actions regardless of commit/abort */
516516
tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
517517
tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
@@ -860,7 +860,7 @@ add_tabstat_xact_level(PgStat_TableStatus *pgstat_info, int nest_level)
860860
* If this is the first rel to be modified at the current nest level, we
861861
* first have to push a transaction stack entry.
862862
*/
863-
xact_state = pgstat_xact_stack_level_get(nest_level);
863+
xact_state = pgstat_get_xact_stack_level(nest_level);
864864

865865
/* Now make a per-table stack entry */
866866
trans = (PgStat_TableXactStatus *)
@@ -897,7 +897,7 @@ ensure_tabstat_xact_level(PgStat_TableStatus *pgstat_info)
897897
* subxact level only.
898898
*/
899899
static void
900-
pgstat_truncdrop_save_counters(PgStat_TableXactStatus *trans, bool is_drop)
900+
save_truncdrop_counters(PgStat_TableXactStatus *trans, bool is_drop)
901901
{
902902
if (!trans->truncdropped || is_drop)
903903
{
@@ -912,7 +912,7 @@ pgstat_truncdrop_save_counters(PgStat_TableXactStatus *trans, bool is_drop)
912912
* restore counters when a truncate aborts
913913
*/
914914
static void
915-
pgstat_truncdrop_restore_counters(PgStat_TableXactStatus *trans)
915+
restore_truncdrop_counters(PgStat_TableXactStatus *trans)
916916
{
917917
if (trans->truncdropped)
918918
{

src/backend/utils/activity/pgstat_slru.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "utils/pgstat_internal.h"
2121

2222

23-
static inline PgStat_MsgSLRU *slru_entry(int slru_idx);
23+
static inline PgStat_MsgSLRU *get_slru_entry(int slru_idx);
2424

2525

2626
/*
@@ -49,7 +49,7 @@ pgstat_reset_slru(const char *name)
4949
return;
5050

5151
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETSLRUCOUNTER);
52-
msg.m_index = pgstat_slru_index(name);
52+
msg.m_index = pgstat_get_slru_index(name);
5353

5454
pgstat_send(&msg, sizeof(msg));
5555
}
@@ -61,43 +61,43 @@ pgstat_reset_slru(const char *name)
6161
void
6262
pgstat_count_slru_page_zeroed(int slru_idx)
6363
{
64-
slru_entry(slru_idx)->m_blocks_zeroed += 1;
64+
get_slru_entry(slru_idx)->m_blocks_zeroed += 1;
6565
}
6666

6767
void
6868
pgstat_count_slru_page_hit(int slru_idx)
6969
{
70-
slru_entry(slru_idx)->m_blocks_hit += 1;
70+
get_slru_entry(slru_idx)->m_blocks_hit += 1;
7171
}
7272

7373
void
7474
pgstat_count_slru_page_exists(int slru_idx)
7575
{
76-
slru_entry(slru_idx)->m_blocks_exists += 1;
76+
get_slru_entry(slru_idx)->m_blocks_exists += 1;
7777
}
7878

7979
void
8080
pgstat_count_slru_page_read(int slru_idx)
8181
{
82-
slru_entry(slru_idx)->m_blocks_read += 1;
82+
get_slru_entry(slru_idx)->m_blocks_read += 1;
8383
}
8484

8585
void
8686
pgstat_count_slru_page_written(int slru_idx)
8787
{
88-
slru_entry(slru_idx)->m_blocks_written += 1;
88+
get_slru_entry(slru_idx)->m_blocks_written += 1;
8989
}
9090

9191
void
9292
pgstat_count_slru_flush(int slru_idx)
9393
{
94-
slru_entry(slru_idx)->m_flush += 1;
94+
get_slru_entry(slru_idx)->m_flush += 1;
9595
}
9696

9797
void
9898
pgstat_count_slru_truncate(int slru_idx)
9999
{
100-
slru_entry(slru_idx)->m_truncate += 1;
100+
get_slru_entry(slru_idx)->m_truncate += 1;
101101
}
102102

103103
/*
@@ -106,7 +106,7 @@ pgstat_count_slru_truncate(int slru_idx)
106106
* know the number of entries in advance.
107107
*/
108108
const char *
109-
pgstat_slru_name(int slru_idx)
109+
pgstat_get_slru_name(int slru_idx)
110110
{
111111
if (slru_idx < 0 || slru_idx >= SLRU_NUM_ELEMENTS)
112112
return NULL;
@@ -120,7 +120,7 @@ pgstat_slru_name(int slru_idx)
120120
* external projects.
121121
*/
122122
int
123-
pgstat_slru_index(const char *name)
123+
pgstat_get_slru_index(const char *name)
124124
{
125125
int i;
126126

@@ -174,7 +174,7 @@ pgstat_send_slru(void)
174174
* stored in SlruCtl as lwlock tranche name).
175175
*/
176176
static inline PgStat_MsgSLRU *
177-
slru_entry(int slru_idx)
177+
get_slru_entry(int slru_idx)
178178
{
179179
pgstat_assert_is_up();
180180

src/backend/utils/activity/pgstat_wal.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pgstat_report_wal(bool force)
130130
}
131131

132132
void
133-
pgstat_wal_initialize(void)
133+
pgstat_init_wal(void)
134134
{
135135
/*
136136
* Initialize prevWalUsage with pgWalUsage so that pgstat_report_wal() can
@@ -148,7 +148,7 @@ pgstat_wal_initialize(void)
148148
* data pages.
149149
*/
150150
bool
151-
pgstat_wal_pending(void)
151+
pgstat_have_pending_wal(void)
152152
{
153153
return pgWalUsage.wal_records != prevWalUsage.wal_records ||
154154
WalStats.m_wal_write != 0 ||

src/backend/utils/activity/pgstat_xact.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ AtEOSubXact_PgStat_DroppedStats(PgStat_SubXactStatus *xact_state,
139139
if (xact_state->pending_drops_count == 0)
140140
return;
141141

142-
parent_xact_state = pgstat_xact_stack_level_get(nestDepth - 1);
142+
parent_xact_state = pgstat_get_xact_stack_level(nestDepth - 1);
143143

144144
dlist_foreach_modify(iter, &xact_state->pending_drops)
145145
{
@@ -228,7 +228,7 @@ PostPrepare_PgStat(void)
228228
* it if needed.
229229
*/
230230
PgStat_SubXactStatus *
231-
pgstat_xact_stack_level_get(int nest_level)
231+
pgstat_get_xact_stack_level(int nest_level)
232232
{
233233
PgStat_SubXactStatus *xact_state;
234234

@@ -324,7 +324,7 @@ create_drop_transactional_internal(PgStat_Kind kind, Oid dboid, Oid objoid, bool
324324
PgStat_PendingDroppedStatsItem *drop = (PgStat_PendingDroppedStatsItem *)
325325
MemoryContextAlloc(TopTransactionContext, sizeof(PgStat_PendingDroppedStatsItem));
326326

327-
xact_state = pgstat_xact_stack_level_get(nest_level);
327+
xact_state = pgstat_get_xact_stack_level(nest_level);
328328

329329
drop->is_create = is_create;
330330
drop->item.kind = kind;

src/backend/utils/adt/pgstatfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
18301830
PgStat_SLRUStats stat;
18311831
const char *name;
18321832

1833-
name = pgstat_slru_name(i);
1833+
name = pgstat_get_slru_name(i);
18341834

18351835
if (!name)
18361836
break;

0 commit comments

Comments
 (0)