Subject: Refactor statistics collector, backend status reporting and command progress reporting

From: Nitin Jadhav <[email-masked]>
Date: Tue, 1 Mar 2022 23:42:02 +0530

Hi,

Following are the files related to PostgreSQL statistics collector,
backend status reporting and command progress reporting.

pgstat.[ch] - Definitions for the PostgreSQL statistics collector daemon.
backend_status.[ch] - Definitions related to backend status reporting.
backend_progress.[ch] - Definitions related to command progress reporting.
progress.h - Constants used with the progress reporting facilities
defined in backend_status.h
pgstatfuncs.c - Functions for accessing the statistics collector data

There is a scope for some refactoring here even though the backend
status and command progress related code is separated from pgstat.c.

1) There is a lot of confusion between progress.h and
backend_progress.h. Why 2 header files required for the same
functionality? I feel progress.h can be merged with
backend_progress.h.
2) The access functions related to statistics collector are included
in pgstatfuncs.c file. This also contains the access functions related
to backend status and backend progress. I feel the access function
related to backend status should go in backend_status.c and the access
functions related to backend progress should go in backend progress.c
file. If the size grows in future then we can create new files for
access functions (like backend_status_funcs.c and
backend_progress_funcs.c).
3) There is a dependency between backend status and command progress
reporting but the corresponding functions are separated into 2
different files. It is better to define a new structure named
'PgBackendProgress' in backend_progress.h which consists of
'st_progress_command', 'st_progress_command_target' and
'st_progress_param'. Include a variable of type 'PgBackendProgress' as
a member of 'PgBackendStatus' structure.

Please share your thoughts.
If required, I would like to work on the patch.

Thanks & Regards,
Nitin Jadhav