Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit edadf80

Browse files
committed
pgstat: consistent function comment formatting.
There was a wild mishmash of function comment formatting in pgstat, making it hard to know what to use for any new function and hard to extend existing comments (particularly due to randomly different forms of indentation). Author: Andres Freund <andres@anarazel.de> Reviewed-By: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/20220329191727.mzzwbl7udhpq7pmf@alap3.anarazel.de Discussion: https://postgr.es/m/20220308205351.2xcn6k4x5yivcxyd@alap3.anarazel.de
1 parent 4e34747 commit edadf80

11 files changed

+300
-608
lines changed

src/backend/postmaster/pgstat.c

+209-427
Large diffs are not rendered by default.

src/backend/utils/activity/pgstat_archiver.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
#include "utils/timestamp.h"
2222

2323

24-
/* ----------
25-
* pgstat_send_archiver() -
26-
*
27-
* Tell the collector about the WAL file that we successfully
28-
* archived or failed to archive.
29-
* ----------
24+
/*
25+
* Tell the collector about the WAL file that we successfully
26+
* archived or failed to archive.
3027
*/
3128
void
3229
pgstat_send_archiver(const char *xlog, bool failed)

src/backend/utils/activity/pgstat_bgwriter.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
PgStat_MsgBgWriter PendingBgWriterStats;
2929

3030

31-
/* ----------
32-
* pgstat_send_bgwriter() -
33-
*
34-
* Send bgwriter statistics to the collector
35-
* ----------
31+
/*
32+
* Send bgwriter statistics to the collector
3633
*/
3734
void
3835
pgstat_send_bgwriter(void)

src/backend/utils/activity/pgstat_checkpointer.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
PgStat_MsgCheckpointer PendingCheckpointerStats;
2929

3030

31-
/* ----------
32-
* pgstat_send_checkpointer() -
33-
*
34-
* Send checkpointer statistics to the collector
35-
* ----------
31+
/*
32+
* Send checkpointer statistics to the collector
3633
*/
3734
void
3835
pgstat_send_checkpointer(void)

src/backend/utils/activity/pgstat_database.c

+24-51
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ SessionEndType pgStatSessionEndCause = DISCONNECT_NORMAL;
3636
static PgStat_Counter pgLastSessionReportTime = 0;
3737

3838

39-
/* ----------
40-
* pgstat_drop_database() -
41-
*
42-
* Tell the collector that we just dropped a database.
43-
* (If the message gets lost, we will still clean the dead DB eventually
44-
* via future invocations of pgstat_vacuum_stat().)
45-
* ----------
39+
/*
40+
* Tell the collector that we just dropped a database.
41+
* (If the message gets lost, we will still clean the dead DB eventually
42+
* via future invocations of pgstat_vacuum_stat().)
4643
*/
4744
void
4845
pgstat_drop_database(Oid databaseid)
@@ -57,11 +54,8 @@ pgstat_drop_database(Oid databaseid)
5754
pgstat_send(&msg, sizeof(msg));
5855
}
5956

60-
/* --------
61-
* pgstat_report_recovery_conflict() -
62-
*
63-
* Tell the collector about a Hot Standby recovery conflict.
64-
* --------
57+
/*
58+
* Tell the collector about a Hot Standby recovery conflict.
6559
*/
6660
void
6761
pgstat_report_recovery_conflict(int reason)
@@ -77,11 +71,8 @@ pgstat_report_recovery_conflict(int reason)
7771
pgstat_send(&msg, sizeof(msg));
7872
}
7973

80-
/* --------
81-
* pgstat_report_deadlock() -
82-
*
83-
* Tell the collector about a deadlock detected.
84-
* --------
74+
/*
75+
* Tell the collector about a deadlock detected.
8576
*/
8677
void
8778
pgstat_report_deadlock(void)
@@ -96,11 +87,8 @@ pgstat_report_deadlock(void)
9687
pgstat_send(&msg, sizeof(msg));
9788
}
9889

99-
/* --------
100-
* pgstat_report_checksum_failures_in_db() -
101-
*
102-
* Tell the collector about one or more checksum failures.
103-
* --------
90+
/*
91+
* Tell the collector about one or more checksum failures.
10492
*/
10593
void
10694
pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
@@ -118,23 +106,17 @@ pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
118106
pgstat_send(&msg, sizeof(msg));
119107
}
120108

121-
/* --------
122-
* pgstat_report_checksum_failure() -
123-
*
124-
* Tell the collector about a checksum failure.
125-
* --------
109+
/*
110+
* Tell the collector about a checksum failure.
126111
*/
127112
void
128113
pgstat_report_checksum_failure(void)
129114
{
130115
pgstat_report_checksum_failures_in_db(MyDatabaseId, 1);
131116
}
132117

133-
/* --------
134-
* pgstat_report_tempfile() -
135-
*
136-
* Tell the collector about a temporary file.
137-
* --------
118+
/*
119+
* Tell the collector about a temporary file.
138120
*/
139121
void
140122
pgstat_report_tempfile(size_t filesize)
@@ -150,11 +132,8 @@ pgstat_report_tempfile(size_t filesize)
150132
pgstat_send(&msg, sizeof(msg));
151133
}
152134

153-
/* --------
154-
* pgstat_report_connect() -
155-
*
156-
* Tell the collector about a new connection.
157-
* --------
135+
/*
136+
* Tell the collector about a new connection.
158137
*/
159138
void
160139
pgstat_report_connect(Oid dboid)
@@ -171,11 +150,8 @@ pgstat_report_connect(Oid dboid)
171150
pgstat_send(&msg, sizeof(PgStat_MsgConnect));
172151
}
173152

174-
/* --------
175-
* pgstat_report_disconnect() -
176-
*
177-
* Tell the collector about a disconnect.
178-
* --------
153+
/*
154+
* Tell the collector about a disconnect.
179155
*/
180156
void
181157
pgstat_report_disconnect(Oid dboid)
@@ -262,15 +238,12 @@ pgstat_update_dbstats(PgStat_MsgTabstat *tsmsg, TimestampTz now)
262238
}
263239
}
264240

265-
/* --------
266-
* pgstat_should_report_connstats() -
267-
*
268-
* We report session statistics only for normal backend processes. Parallel
269-
* workers run in parallel, so they don't contribute to session times, even
270-
* though they use CPU time. Walsender processes could be considered here,
271-
* but they have different session characteristics from normal backends (for
272-
* example, they are always "active"), so they would skew session statistics.
273-
* ----------
241+
/*
242+
* We report session statistics only for normal backend processes. Parallel
243+
* workers run in parallel, so they don't contribute to session times, even
244+
* though they use CPU time. Walsender processes could be considered here,
245+
* but they have different session characteristics from normal backends (for
246+
* example, they are always "active"), so they would skew session statistics.
274247
*/
275248
static bool
276249
pgstat_should_report_connstat(void)

src/backend/utils/activity/pgstat_function.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ pgstat_send_funcstats(void)
206206
}
207207

208208
/*
209-
* find_funcstat_entry - find any existing PgStat_BackendFunctionEntry entry
210-
* for specified function
209+
* find any existing PgStat_BackendFunctionEntry entry for specified function
211210
*
212211
* If no entry, return NULL, don't create a new one
213212
*/

src/backend/utils/activity/pgstat_relation.c

+30-47
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,14 @@ bool have_relation_stats;
9595
static HTAB *pgStatTabHash = NULL;
9696

9797

98-
/* ----------
99-
* pgstat_relation_init() -
100-
*
101-
* Initialize a relcache entry to count access statistics.
102-
* Called whenever a relation is opened.
98+
/*
99+
* Initialize a relcache entry to count access statistics.
100+
* Called whenever a relation is opened.
103101
*
104-
* We assume that a relcache entry's pgstat_info field is zeroed by
105-
* relcache.c when the relcache entry is made; thereafter it is long-lived
106-
* data. We can avoid repeated searches of the TabStatus arrays when the
107-
* same relation is touched repeatedly within a transaction.
108-
* ----------
102+
* We assume that a relcache entry's pgstat_info field is zeroed by
103+
* relcache.c when the relcache entry is made; thereafter it is long-lived
104+
* data. We can avoid repeated searches of the TabStatus arrays when the
105+
* same relation is touched repeatedly within a transaction.
109106
*/
110107
void
111108
pgstat_relation_init(Relation rel)
@@ -141,16 +138,13 @@ pgstat_relation_init(Relation rel)
141138
rel->pgstat_info = get_tabstat_entry(rel_id, rel->rd_rel->relisshared);
142139
}
143140

144-
/* ----------
145-
* pgstat_drop_relation() -
146-
*
147-
* Tell the collector that we just dropped a relation.
148-
* (If the message gets lost, we will still clean the dead entry eventually
149-
* via future invocations of pgstat_vacuum_stat().)
141+
/*
142+
* Tell the collector that we just dropped a relation.
143+
* (If the message gets lost, we will still clean the dead entry eventually
144+
* via future invocations of pgstat_vacuum_stat().)
150145
*
151-
* Currently not used for lack of any good place to call it; we rely
152-
* entirely on pgstat_vacuum_stat() to clean out stats for dead rels.
153-
* ----------
146+
* Currently not used for lack of any good place to call it; we rely
147+
* entirely on pgstat_vacuum_stat() to clean out stats for dead rels.
154148
*/
155149
#ifdef NOT_USED
156150
void
@@ -173,13 +167,10 @@ pgstat_drop_relation(Oid relid)
173167
}
174168
#endif /* NOT_USED */
175169

176-
/* ----------
177-
* pgstat_report_autovac() -
178-
*
179-
* Called from autovacuum.c to report startup of an autovacuum process.
180-
* We are called before InitPostgres is done, so can't rely on MyDatabaseId;
181-
* the db OID must be passed in, instead.
182-
* ----------
170+
/*
171+
* Called from autovacuum.c to report startup of an autovacuum process.
172+
* We are called before InitPostgres is done, so can't rely on MyDatabaseId;
173+
* the db OID must be passed in, instead.
183174
*/
184175
void
185176
pgstat_report_autovac(Oid dboid)
@@ -196,11 +187,8 @@ pgstat_report_autovac(Oid dboid)
196187
pgstat_send(&msg, sizeof(msg));
197188
}
198189

199-
/* ---------
200-
* pgstat_report_vacuum() -
201-
*
202-
* Tell the collector about the table we just vacuumed.
203-
* ---------
190+
/*
191+
* Tell the collector about the table we just vacuumed.
204192
*/
205193
void
206194
pgstat_report_vacuum(Oid tableoid, bool shared,
@@ -221,14 +209,11 @@ pgstat_report_vacuum(Oid tableoid, bool shared,
221209
pgstat_send(&msg, sizeof(msg));
222210
}
223211

224-
/* --------
225-
* pgstat_report_analyze() -
226-
*
227-
* Tell the collector about the table we just analyzed.
212+
/*
213+
* Tell the collector about the table we just analyzed.
228214
*
229215
* Caller must provide new live- and dead-tuples estimates, as well as a
230216
* flag indicating whether to reset the changes_since_analyze counter.
231-
* --------
232217
*/
233218
void
234219
pgstat_report_analyze(Relation rel,
@@ -281,7 +266,7 @@ pgstat_report_analyze(Relation rel,
281266
}
282267

283268
/*
284-
* pgstat_count_heap_insert - count a tuple insertion of n tuples
269+
* count a tuple insertion of n tuples
285270
*/
286271
void
287272
pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
@@ -296,7 +281,7 @@ pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
296281
}
297282

298283
/*
299-
* pgstat_count_heap_update - count a tuple update
284+
* count a tuple update
300285
*/
301286
void
302287
pgstat_count_heap_update(Relation rel, bool hot)
@@ -315,7 +300,7 @@ pgstat_count_heap_update(Relation rel, bool hot)
315300
}
316301

317302
/*
318-
* pgstat_count_heap_delete - count a tuple deletion
303+
* count a tuple deletion
319304
*/
320305
void
321306
pgstat_count_heap_delete(Relation rel)
@@ -330,7 +315,7 @@ pgstat_count_heap_delete(Relation rel)
330315
}
331316

332317
/*
333-
* pgstat_count_truncate - update tuple counters due to truncate
318+
* update tuple counters due to truncate
334319
*/
335320
void
336321
pgstat_count_truncate(Relation rel)
@@ -348,7 +333,7 @@ pgstat_count_truncate(Relation rel)
348333
}
349334

350335
/*
351-
* pgstat_update_heap_dead_tuples - update dead-tuples count
336+
* update dead-tuples count
352337
*
353338
* The semantics of this are that we are reporting the nontransactional
354339
* recovery of "delta" dead tuples; so t_delta_dead_tuples decreases
@@ -367,7 +352,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
367352
}
368353

369354
/*
370-
* find_tabstat_entry - find any existing PgStat_TableStatus entry for rel
355+
* find any existing PgStat_TableStatus entry for rel
371356
*
372357
* If no entry, return NULL, don't create a new one
373358
*
@@ -772,7 +757,7 @@ pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg, TimestampTz now)
772757
}
773758

774759
/*
775-
* get_tabstat_entry - find or create a PgStat_TableStatus entry for rel
760+
* find or create a PgStat_TableStatus entry for rel
776761
*/
777762
static PgStat_TableStatus *
778763
get_tabstat_entry(Oid rel_id, bool isshared)
@@ -858,7 +843,7 @@ get_tabstat_entry(Oid rel_id, bool isshared)
858843
}
859844

860845
/*
861-
* add_tabstat_xact_level - add a new (sub)transaction state record
846+
* add a new (sub)transaction state record
862847
*/
863848
static void
864849
add_tabstat_xact_level(PgStat_TableStatus *pgstat_info, int nest_level)
@@ -898,8 +883,6 @@ ensure_tabstat_xact_level(PgStat_TableStatus *pgstat_info)
898883
}
899884

900885
/*
901-
* pgstat_truncdrop_save_counters
902-
*
903886
* Whenever a table is truncated/dropped, we save its i/u/d counters so that
904887
* they can be cleared, and if the (sub)xact that executed the truncate/drop
905888
* later aborts, the counters can be restored to the saved (pre-truncate/drop)
@@ -921,7 +904,7 @@ pgstat_truncdrop_save_counters(PgStat_TableXactStatus *trans, bool is_drop)
921904
}
922905

923906
/*
924-
* pgstat_truncdrop_restore_counters - restore counters when a truncate aborts
907+
* restore counters when a truncate aborts
925908
*/
926909
static void
927910
pgstat_truncdrop_restore_counters(PgStat_TableXactStatus *trans)

0 commit comments

Comments
 (0)