]> granicus.if.org Git - postgresql/blob - src/include/pgstat.h
Create a type-specific typanalyze routine for tsvector, which collects stats
[postgresql] / src / include / pgstat.h
1 /* ----------
2  *      pgstat.h
3  *
4  *      Definitions for the PostgreSQL statistics collector daemon.
5  *
6  *      Copyright (c) 2001-2008, PostgreSQL Global Development Group
7  *
8  *      $PostgreSQL: pgsql/src/include/pgstat.h,v 1.77 2008/06/30 10:58:47 heikki Exp $
9  * ----------
10  */
11 #ifndef PGSTAT_H
12 #define PGSTAT_H
13
14 #include "libpq/pqcomm.h"
15 #include "portability/instr_time.h"
16 #include "utils/hsearch.h"
17 #include "utils/relcache.h"
18 #include "utils/timestamp.h"
19
20
21 /* Values for track_functions GUC variable --- order is significant! */
22 typedef enum TrackFunctionsLevel
23 {
24         TRACK_FUNC_OFF,
25         TRACK_FUNC_PL,
26         TRACK_FUNC_ALL
27 } TrackFunctionsLevel;
28
29 /* ----------
30  * The types of backend -> collector messages
31  * ----------
32  */
33 typedef enum StatMsgType
34 {
35         PGSTAT_MTYPE_DUMMY,
36         PGSTAT_MTYPE_TABSTAT,
37         PGSTAT_MTYPE_TABPURGE,
38         PGSTAT_MTYPE_DROPDB,
39         PGSTAT_MTYPE_RESETCOUNTER,
40         PGSTAT_MTYPE_AUTOVAC_START,
41         PGSTAT_MTYPE_VACUUM,
42         PGSTAT_MTYPE_ANALYZE,
43         PGSTAT_MTYPE_BGWRITER,
44         PGSTAT_MTYPE_FUNCSTAT,
45         PGSTAT_MTYPE_FUNCPURGE
46 } StatMsgType;
47
48 /* ----------
49  * The data type used for counters.
50  * ----------
51  */
52 typedef int64 PgStat_Counter;
53
54 /* ----------
55  * PgStat_TableCounts                   The actual per-table counts kept by a backend
56  *
57  * This struct should contain only actual event counters, because we memcmp
58  * it against zeroes to detect whether there are any counts to transmit.
59  * It is a component of PgStat_TableStatus (within-backend state) and
60  * PgStat_TableEntry (the transmitted message format).
61  *
62  * Note: for a table, tuples_returned is the number of tuples successfully
63  * fetched by heap_getnext, while tuples_fetched is the number of tuples
64  * successfully fetched by heap_fetch under the control of bitmap indexscans.
65  * For an index, tuples_returned is the number of index entries returned by
66  * the index AM, while tuples_fetched is the number of tuples successfully
67  * fetched by heap_fetch under the control of simple indexscans for this index.
68  *
69  * tuples_inserted/updated/deleted/hot_updated count attempted actions,
70  * regardless of whether the transaction committed.  new_live_tuples and
71  * new_dead_tuples are properly adjusted depending on commit or abort.
72  * Note that new_live_tuples and new_dead_tuples can be negative!
73  * ----------
74  */
75 typedef struct PgStat_TableCounts
76 {
77         PgStat_Counter t_numscans;
78
79         PgStat_Counter t_tuples_returned;
80         PgStat_Counter t_tuples_fetched;
81
82         PgStat_Counter t_tuples_inserted;
83         PgStat_Counter t_tuples_updated;
84         PgStat_Counter t_tuples_deleted;
85         PgStat_Counter t_tuples_hot_updated;
86
87         PgStat_Counter t_new_live_tuples;
88         PgStat_Counter t_new_dead_tuples;
89
90         PgStat_Counter t_blocks_fetched;
91         PgStat_Counter t_blocks_hit;
92 } PgStat_TableCounts;
93
94
95 /* ------------------------------------------------------------
96  * Structures kept in backend local memory while accumulating counts
97  * ------------------------------------------------------------
98  */
99
100
101 /* ----------
102  * PgStat_TableStatus                   Per-table status within a backend
103  *
104  * Most of the event counters are nontransactional, ie, we count events
105  * in committed and aborted transactions alike.  For these, we just count
106  * directly in the PgStat_TableStatus.  However, new_live_tuples and
107  * new_dead_tuples must be derived from tuple insertion and deletion counts
108  * with awareness of whether the transaction or subtransaction committed or
109  * aborted.  Hence, we also keep a stack of per-(sub)transaction status
110  * records for every table modified in the current transaction.  At commit
111  * or abort, we propagate tuples_inserted and tuples_deleted up to the
112  * parent subtransaction level, or out to the parent PgStat_TableStatus,
113  * as appropriate.
114  * ----------
115  */
116 typedef struct PgStat_TableStatus
117 {
118         Oid                     t_id;                   /* table's OID */
119         bool            t_shared;               /* is it a shared catalog? */
120         struct PgStat_TableXactStatus *trans;           /* lowest subxact's counts */
121         PgStat_TableCounts t_counts;    /* event counts to be sent */
122 } PgStat_TableStatus;
123
124 /* ----------
125  * PgStat_TableXactStatus               Per-table, per-subtransaction status
126  * ----------
127  */
128 typedef struct PgStat_TableXactStatus
129 {
130         PgStat_Counter tuples_inserted;         /* tuples inserted in (sub)xact */
131         PgStat_Counter tuples_deleted;          /* tuples deleted in (sub)xact */
132         int                     nest_level;             /* subtransaction nest level */
133         /* links to other structs for same relation: */
134         struct PgStat_TableXactStatus *upper;           /* next higher subxact if any */
135         PgStat_TableStatus *parent; /* per-table status */
136         /* structs of same subxact level are linked here: */
137         struct PgStat_TableXactStatus *next;            /* next of same subxact */
138 } PgStat_TableXactStatus;
139
140
141 /* ------------------------------------------------------------
142  * Message formats follow
143  * ------------------------------------------------------------
144  */
145
146
147 /* ----------
148  * PgStat_MsgHdr                                The common message header
149  * ----------
150  */
151 typedef struct PgStat_MsgHdr
152 {
153         StatMsgType m_type;
154         int                     m_size;
155 } PgStat_MsgHdr;
156
157 /* ----------
158  * Space available in a message.  This will keep the UDP packets below 1K,
159  * which should fit unfragmented into the MTU of the lo interface on most
160  * platforms. Does anybody care for platforms where it doesn't?
161  * ----------
162  */
163 #define PGSTAT_MSG_PAYLOAD      (1000 - sizeof(PgStat_MsgHdr))
164
165
166 /* ----------
167  * PgStat_MsgDummy                              A dummy message, ignored by the collector
168  * ----------
169  */
170 typedef struct PgStat_MsgDummy
171 {
172         PgStat_MsgHdr m_hdr;
173 } PgStat_MsgDummy;
174
175
176 /* ----------
177  * PgStat_TableEntry                    Per-table info in a MsgTabstat
178  * ----------
179  */
180 typedef struct PgStat_TableEntry
181 {
182         Oid                     t_id;
183         PgStat_TableCounts t_counts;
184 } PgStat_TableEntry;
185
186 /* ----------
187  * PgStat_MsgTabstat                    Sent by the backend to report table
188  *                                                              and buffer access statistics.
189  * ----------
190  */
191 #define PGSTAT_NUM_TABENTRIES  \
192         ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - 3 * sizeof(int))  \
193          / sizeof(PgStat_TableEntry))
194
195 typedef struct PgStat_MsgTabstat
196 {
197         PgStat_MsgHdr m_hdr;
198         Oid                     m_databaseid;
199         int                     m_nentries;
200         int                     m_xact_commit;
201         int                     m_xact_rollback;
202         PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES];
203 } PgStat_MsgTabstat;
204
205
206 /* ----------
207  * PgStat_MsgTabpurge                   Sent by the backend to tell the collector
208  *                                                              about dead tables.
209  * ----------
210  */
211 #define PGSTAT_NUM_TABPURGE  \
212         ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int))  \
213          / sizeof(Oid))
214
215 typedef struct PgStat_MsgTabpurge
216 {
217         PgStat_MsgHdr m_hdr;
218         Oid                     m_databaseid;
219         int                     m_nentries;
220         Oid                     m_tableid[PGSTAT_NUM_TABPURGE];
221 } PgStat_MsgTabpurge;
222
223
224 /* ----------
225  * PgStat_MsgDropdb                             Sent by the backend to tell the collector
226  *                                                              about a dropped database
227  * ----------
228  */
229 typedef struct PgStat_MsgDropdb
230 {
231         PgStat_MsgHdr m_hdr;
232         Oid                     m_databaseid;
233 } PgStat_MsgDropdb;
234
235
236 /* ----------
237  * PgStat_MsgResetcounter               Sent by the backend to tell the collector
238  *                                                              to reset counters
239  * ----------
240  */
241 typedef struct PgStat_MsgResetcounter
242 {
243         PgStat_MsgHdr m_hdr;
244         Oid                     m_databaseid;
245 } PgStat_MsgResetcounter;
246
247
248 /* ----------
249  * PgStat_MsgAutovacStart               Sent by the autovacuum daemon to signal
250  *                                                              that a database is going to be processed
251  * ----------
252  */
253 typedef struct PgStat_MsgAutovacStart
254 {
255         PgStat_MsgHdr m_hdr;
256         Oid                     m_databaseid;
257         TimestampTz m_start_time;
258 } PgStat_MsgAutovacStart;
259
260
261 /* ----------
262  * PgStat_MsgVacuum                             Sent by the backend or autovacuum daemon
263  *                                                              after VACUUM or VACUUM ANALYZE
264  * ----------
265  */
266 typedef struct PgStat_MsgVacuum
267 {
268         PgStat_MsgHdr m_hdr;
269         Oid                     m_databaseid;
270         Oid                     m_tableoid;
271         bool            m_analyze;
272         bool            m_autovacuum;
273         TimestampTz m_vacuumtime;
274         PgStat_Counter m_tuples;
275 } PgStat_MsgVacuum;
276
277
278 /* ----------
279  * PgStat_MsgAnalyze                    Sent by the backend or autovacuum daemon
280  *                                                              after ANALYZE
281  * ----------
282  */
283 typedef struct PgStat_MsgAnalyze
284 {
285         PgStat_MsgHdr m_hdr;
286         Oid                     m_databaseid;
287         Oid                     m_tableoid;
288         bool            m_autovacuum;
289         TimestampTz m_analyzetime;
290         PgStat_Counter m_live_tuples;
291         PgStat_Counter m_dead_tuples;
292 } PgStat_MsgAnalyze;
293
294
295 /* ----------
296  * PgStat_MsgBgWriter                   Sent by the bgwriter to update statistics.
297  * ----------
298  */
299 typedef struct PgStat_MsgBgWriter
300 {
301         PgStat_MsgHdr m_hdr;
302
303         PgStat_Counter m_timed_checkpoints;
304         PgStat_Counter m_requested_checkpoints;
305         PgStat_Counter m_buf_written_checkpoints;
306         PgStat_Counter m_buf_written_clean;
307         PgStat_Counter m_maxwritten_clean;
308         PgStat_Counter m_buf_written_backend;
309         PgStat_Counter m_buf_alloc;
310 } PgStat_MsgBgWriter;
311
312
313 /* ----------
314  * PgStat_FunctionCounts        The actual per-function counts kept by a backend
315  *
316  * This struct should contain only actual event counters, because we memcmp
317  * it against zeroes to detect whether there are any counts to transmit.
318  *
319  * Note that the time counters are in instr_time format here.  We convert to
320  * microseconds in PgStat_Counter format when transmitting to the collector.
321  * ----------
322  */
323 typedef struct PgStat_FunctionCounts
324 {
325         PgStat_Counter f_numcalls;
326         instr_time      f_time;
327         instr_time      f_time_self;
328 } PgStat_FunctionCounts;
329
330 /* ----------
331  * PgStat_BackendFunctionEntry  Entry in backend's per-function hash table
332  * ----------
333  */
334 typedef struct PgStat_BackendFunctionEntry
335 {
336         Oid                     f_id;
337         PgStat_FunctionCounts f_counts;
338 } PgStat_BackendFunctionEntry;
339
340 /* ----------
341  * PgStat_FunctionEntry                 Per-function info in a MsgFuncstat
342  * ----------
343  */
344 typedef struct PgStat_FunctionEntry
345 {
346         Oid                     f_id;
347         PgStat_Counter f_numcalls;
348         PgStat_Counter f_time;          /* times in microseconds */
349         PgStat_Counter f_time_self;
350 } PgStat_FunctionEntry;
351
352 /* ----------
353  * PgStat_MsgFuncstat                   Sent by the backend to report function
354  *                                                              usage statistics.
355  * ----------
356  */
357 #define PGSTAT_NUM_FUNCENTRIES  \
358         ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int))  \
359          / sizeof(PgStat_FunctionEntry))
360
361 typedef struct PgStat_MsgFuncstat
362 {
363         PgStat_MsgHdr m_hdr;
364         Oid                     m_databaseid;
365         int                     m_nentries;
366         PgStat_FunctionEntry m_entry[PGSTAT_NUM_FUNCENTRIES];
367 } PgStat_MsgFuncstat;
368
369 /* ----------
370  * PgStat_MsgFuncpurge                  Sent by the backend to tell the collector
371  *                                                              about dead functions.
372  * ----------
373  */
374 #define PGSTAT_NUM_FUNCPURGE  \
375         ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int))  \
376          / sizeof(Oid))
377
378 typedef struct PgStat_MsgFuncpurge
379 {
380         PgStat_MsgHdr m_hdr;
381         Oid                     m_databaseid;
382         int                     m_nentries;
383         Oid                     m_functionid[PGSTAT_NUM_FUNCPURGE];
384 } PgStat_MsgFuncpurge;
385
386
387 /* ----------
388  * PgStat_Msg                                   Union over all possible messages.
389  * ----------
390  */
391 typedef union PgStat_Msg
392 {
393         PgStat_MsgHdr msg_hdr;
394         PgStat_MsgDummy msg_dummy;
395         PgStat_MsgTabstat msg_tabstat;
396         PgStat_MsgTabpurge msg_tabpurge;
397         PgStat_MsgDropdb msg_dropdb;
398         PgStat_MsgResetcounter msg_resetcounter;
399         PgStat_MsgAutovacStart msg_autovacuum;
400         PgStat_MsgVacuum msg_vacuum;
401         PgStat_MsgAnalyze msg_analyze;
402         PgStat_MsgBgWriter msg_bgwriter;
403         PgStat_MsgFuncstat msg_funcstat;
404         PgStat_MsgFuncpurge msg_funcpurge;
405 } PgStat_Msg;
406
407
408 /* ------------------------------------------------------------
409  * Statistic collector data structures follow
410  *
411  * PGSTAT_FILE_FORMAT_ID should be changed whenever any of these
412  * data structures change.
413  * ------------------------------------------------------------
414  */
415
416 #define PGSTAT_FILE_FORMAT_ID   0x01A5BC97
417
418 /* ----------
419  * PgStat_StatDBEntry                   The collector's data per database
420  * ----------
421  */
422 typedef struct PgStat_StatDBEntry
423 {
424         Oid                     databaseid;
425         PgStat_Counter n_xact_commit;
426         PgStat_Counter n_xact_rollback;
427         PgStat_Counter n_blocks_fetched;
428         PgStat_Counter n_blocks_hit;
429         PgStat_Counter n_tuples_returned;
430         PgStat_Counter n_tuples_fetched;
431         PgStat_Counter n_tuples_inserted;
432         PgStat_Counter n_tuples_updated;
433         PgStat_Counter n_tuples_deleted;
434         TimestampTz last_autovac_time;
435
436         /*
437          * tables and functions must be last in the struct, because we don't
438          * write the pointers out to the stats file.
439          */
440         HTAB       *tables;
441         HTAB       *functions;
442 } PgStat_StatDBEntry;
443
444
445 /* ----------
446  * PgStat_StatTabEntry                  The collector's data per table (or index)
447  * ----------
448  */
449 typedef struct PgStat_StatTabEntry
450 {
451         Oid                     tableid;
452
453         PgStat_Counter numscans;
454
455         PgStat_Counter tuples_returned;
456         PgStat_Counter tuples_fetched;
457
458         PgStat_Counter tuples_inserted;
459         PgStat_Counter tuples_updated;
460         PgStat_Counter tuples_deleted;
461         PgStat_Counter tuples_hot_updated;
462
463         PgStat_Counter n_live_tuples;
464         PgStat_Counter n_dead_tuples;
465         PgStat_Counter last_anl_tuples;
466
467         PgStat_Counter blocks_fetched;
468         PgStat_Counter blocks_hit;
469
470         TimestampTz vacuum_timestamp;           /* user initiated vacuum */
471         TimestampTz autovac_vacuum_timestamp;           /* autovacuum initiated */
472         TimestampTz analyze_timestamp;          /* user initiated */
473         TimestampTz autovac_analyze_timestamp;          /* autovacuum initiated */
474 } PgStat_StatTabEntry;
475
476
477 /* ----------
478  * PgStat_StatFuncEntry                 The collector's data per function
479  * ----------
480  */
481 typedef struct PgStat_StatFuncEntry
482 {
483         Oid                     functionid;
484
485         PgStat_Counter f_numcalls;
486
487         PgStat_Counter f_time;          /* times in microseconds */
488         PgStat_Counter f_time_self;
489 } PgStat_StatFuncEntry;
490
491
492 /*
493  * Global statistics kept in the stats collector
494  */
495 typedef struct PgStat_GlobalStats
496 {
497         PgStat_Counter timed_checkpoints;
498         PgStat_Counter requested_checkpoints;
499         PgStat_Counter buf_written_checkpoints;
500         PgStat_Counter buf_written_clean;
501         PgStat_Counter maxwritten_clean;
502         PgStat_Counter buf_written_backend;
503         PgStat_Counter buf_alloc;
504 } PgStat_GlobalStats;
505
506
507 /* ----------
508  * Shared-memory data structures
509  * ----------
510  */
511
512 /* ----------
513  * PgBackendStatus
514  *
515  * Each live backend maintains a PgBackendStatus struct in shared memory
516  * showing its current activity.  (The structs are allocated according to
517  * BackendId, but that is not critical.)  Note that the collector process
518  * has no involvement in, or even access to, these structs.
519  * ----------
520  */
521 typedef struct PgBackendStatus
522 {
523         /*
524          * To avoid locking overhead, we use the following protocol: a backend
525          * increments st_changecount before modifying its entry, and again after
526          * finishing a modification.  A would-be reader should note the value of
527          * st_changecount, copy the entry into private memory, then check
528          * st_changecount again.  If the value hasn't changed, and if it's even,
529          * the copy is valid; otherwise start over.  This makes updates cheap
530          * while reads are potentially expensive, but that's the tradeoff we want.
531          */
532         int                     st_changecount;
533
534         /* The entry is valid iff st_procpid > 0, unused if st_procpid == 0 */
535         int                     st_procpid;
536
537         /* Times when current backend, transaction, and activity started */
538         TimestampTz st_proc_start_timestamp;
539         TimestampTz st_xact_start_timestamp;
540         TimestampTz st_activity_start_timestamp;
541
542         /* Database OID, owning user's OID, connection client address */
543         Oid                     st_databaseid;
544         Oid                     st_userid;
545         SockAddr        st_clientaddr;
546
547         /* Is backend currently waiting on an lmgr lock? */
548         bool            st_waiting;
549
550         /* current command string; MUST be null-terminated */
551         char       *st_activity;
552 } PgBackendStatus;
553
554 /*
555  * Working state needed to accumulate per-function-call timing statistics.
556  */
557 typedef struct PgStat_FunctionCallUsage
558 {
559         /* Link to function's hashtable entry (must still be there at exit!) */
560         /* NULL means we are not tracking the current function call */
561         PgStat_FunctionCounts *fs;
562         /* Total time previously charged to function, as of function start */
563         instr_time              save_f_time;
564         /* Backend-wide total time as of function start */
565         instr_time              save_total;
566         /* system clock as of function start */
567         instr_time              f_start;
568 } PgStat_FunctionCallUsage;
569
570
571 /* ----------
572  * GUC parameters
573  * ----------
574  */
575 extern bool pgstat_track_activities;
576 extern bool pgstat_track_counts;
577 extern int      pgstat_track_functions;
578 extern int      pgstat_track_activity_query_size;
579
580 /*
581  * BgWriter statistics counters are updated directly by bgwriter and bufmgr
582  */
583 extern PgStat_MsgBgWriter BgWriterStats;
584
585 /* ----------
586  * Functions called from postmaster
587  * ----------
588  */
589 extern Size BackendStatusShmemSize(void);
590 extern void CreateSharedBackendStatus(void);
591
592 extern void pgstat_init(void);
593 extern int      pgstat_start(void);
594 extern void pgstat_reset_all(void);
595 extern void allow_immediate_pgstat_restart(void);
596
597 #ifdef EXEC_BACKEND
598 extern void PgstatCollectorMain(int argc, char *argv[]);
599 #endif
600
601
602 /* ----------
603  * Functions called from backends
604  * ----------
605  */
606 extern void pgstat_ping(void);
607
608 extern void pgstat_report_stat(bool force);
609 extern void pgstat_vacuum_stat(void);
610 extern void pgstat_drop_database(Oid databaseid);
611
612 extern void pgstat_clear_snapshot(void);
613 extern void pgstat_reset_counters(void);
614
615 extern void pgstat_report_autovac(Oid dboid);
616 extern void pgstat_report_vacuum(Oid tableoid, bool shared,
617                                          bool analyze, PgStat_Counter tuples);
618 extern void pgstat_report_analyze(Relation rel,
619                                           PgStat_Counter livetuples,
620                                           PgStat_Counter deadtuples);
621
622 extern void pgstat_initialize(void);
623 extern void pgstat_bestart(void);
624
625 extern void pgstat_report_activity(const char *what);
626 extern void pgstat_report_xact_timestamp(TimestampTz tstamp);
627 extern void pgstat_report_waiting(bool waiting);
628 extern const char *pgstat_get_backend_current_activity(int pid, bool checkUser);
629
630 extern void pgstat_initstats(Relation rel);
631
632 /* nontransactional event counts are simple enough to inline */
633
634 #define pgstat_count_heap_scan(rel)                                                                     \
635         do {                                                                                                                    \
636                 if (pgstat_track_counts && (rel)->pgstat_info != NULL)          \
637                         (rel)->pgstat_info->t_counts.t_numscans++;                              \
638         } while (0)
639 #define pgstat_count_heap_getnext(rel)                                                          \
640         do {                                                                                                                    \
641                 if (pgstat_track_counts && (rel)->pgstat_info != NULL)          \
642                         (rel)->pgstat_info->t_counts.t_tuples_returned++;               \
643         } while (0)
644 #define pgstat_count_heap_fetch(rel)                                                            \
645         do {                                                                                                                    \
646                 if (pgstat_track_counts && (rel)->pgstat_info != NULL)          \
647                         (rel)->pgstat_info->t_counts.t_tuples_fetched++;                \
648         } while (0)
649 #define pgstat_count_index_scan(rel)                                                            \
650         do {                                                                                                                    \
651                 if (pgstat_track_counts && (rel)->pgstat_info != NULL)          \
652                         (rel)->pgstat_info->t_counts.t_numscans++;                              \
653         } while (0)
654 #define pgstat_count_index_tuples(rel, n)                                                       \
655         do {                                                                                                                    \
656                 if (pgstat_track_counts && (rel)->pgstat_info != NULL)          \
657                         (rel)->pgstat_info->t_counts.t_tuples_returned += (n);  \
658         } while (0)
659 #define pgstat_count_buffer_read(rel)                                                           \
660         do {                                                                                                                    \
661                 if (pgstat_track_counts && (rel)->pgstat_info != NULL)          \
662                         (rel)->pgstat_info->t_counts.t_blocks_fetched++;                \
663         } while (0)
664 #define pgstat_count_buffer_hit(rel)                                                            \
665         do {                                                                                                                    \
666                 if (pgstat_track_counts && (rel)->pgstat_info != NULL)          \
667                         (rel)->pgstat_info->t_counts.t_blocks_hit++;                    \
668         } while (0)
669
670 extern void pgstat_count_heap_insert(Relation rel);
671 extern void pgstat_count_heap_update(Relation rel, bool hot);
672 extern void pgstat_count_heap_delete(Relation rel);
673 extern void pgstat_update_heap_dead_tuples(Relation rel, int delta);
674
675 extern void pgstat_init_function_usage(FunctionCallInfoData *fcinfo,
676                                                                            PgStat_FunctionCallUsage *fcu);
677 extern void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu,
678                                                                           bool finalize);
679
680 extern void AtEOXact_PgStat(bool isCommit);
681 extern void AtEOSubXact_PgStat(bool isCommit, int nestDepth);
682
683 extern void AtPrepare_PgStat(void);
684 extern void PostPrepare_PgStat(void);
685
686 extern void pgstat_twophase_postcommit(TransactionId xid, uint16 info,
687                                                    void *recdata, uint32 len);
688 extern void pgstat_twophase_postabort(TransactionId xid, uint16 info,
689                                                   void *recdata, uint32 len);
690
691 extern void pgstat_send_bgwriter(void);
692
693 /* ----------
694  * Support functions for the SQL-callable functions to
695  * generate the pgstat* views.
696  * ----------
697  */
698 extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dbid);
699 extern PgStat_StatTabEntry *pgstat_fetch_stat_tabentry(Oid relid);
700 extern PgBackendStatus *pgstat_fetch_stat_beentry(int beid);
701 extern PgStat_StatFuncEntry *pgstat_fetch_stat_funcentry(Oid funcid);
702 extern int      pgstat_fetch_stat_numbackends(void);
703 extern PgStat_GlobalStats *pgstat_fetch_global(void);
704
705 #endif   /* PGSTAT_H */