mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Rename some support functions for pgstat* views.
Presently, pgstat_fetch_stat_beentry() accepts a session's backend
ID as its argument, and pgstat_fetch_stat_local_beentry() accepts a
1-based index in an internal array as its argument. The former is
typically used wherever a user must provide a backend ID, and the
latter is usually used internally when looping over all entries in
the array. This difference was first introduced by d7e39d72ca.
Before that commit, both functions accepted a 1-based index to the
internal array.
This commit renames these two functions to make it clear whether
they use the backend ID or the 1-based index to look up the entry.
This is preparatory work for a follow-up change that will introduce
a function for looking up a LocalPgBackendStatus using a backend
ID.
Reviewed-by: Ian Barwick, Sami Imseih, Michael Paquier, Robert Haas
Discussion: https://postgr.es/m/CAB8KJ%3Dj-ACb3H4L9a_b3ZG3iCYDW5aEu3WsPAzkm2S7JzS1Few%40mail.gmail.com
Backpatch-through: 16
This commit is contained in:
@@ -849,8 +849,8 @@ pgstat_read_current_status(void)
|
||||
/*
|
||||
* The BackendStatusArray index is exactly the BackendId of the
|
||||
* source backend. Note that this means localBackendStatusTable
|
||||
* is in order by backend_id. pgstat_fetch_stat_beentry() depends
|
||||
* on that.
|
||||
* is in order by backend_id. pgstat_get_beentry_by_backend_id()
|
||||
* depends on that.
|
||||
*/
|
||||
localentry->backend_id = i;
|
||||
BackendIdGetTransactionIds(i,
|
||||
@@ -1073,21 +1073,21 @@ cmp_lbestatus(const void *a, const void *b)
|
||||
}
|
||||
|
||||
/* ----------
|
||||
* pgstat_fetch_stat_beentry() -
|
||||
* pgstat_get_beentry_by_backend_id() -
|
||||
*
|
||||
* Support function for the SQL-callable pgstat* functions. Returns
|
||||
* our local copy of the current-activity entry for one backend,
|
||||
* or NULL if the given beid doesn't identify any known session.
|
||||
*
|
||||
* The beid argument is the BackendId of the desired session
|
||||
* (note that this is unlike pgstat_fetch_stat_local_beentry()).
|
||||
* (note that this is unlike pgstat_get_local_beentry_by_index()).
|
||||
*
|
||||
* NB: caller is responsible for a check if the user is permitted to see
|
||||
* this info (especially the querystring).
|
||||
* ----------
|
||||
*/
|
||||
PgBackendStatus *
|
||||
pgstat_fetch_stat_beentry(BackendId beid)
|
||||
pgstat_get_beentry_by_backend_id(BackendId beid)
|
||||
{
|
||||
LocalPgBackendStatus key;
|
||||
LocalPgBackendStatus *ret;
|
||||
@@ -1111,13 +1111,13 @@ pgstat_fetch_stat_beentry(BackendId beid)
|
||||
|
||||
|
||||
/* ----------
|
||||
* pgstat_fetch_stat_local_beentry() -
|
||||
* pgstat_get_local_beentry_by_index() -
|
||||
*
|
||||
* Like pgstat_fetch_stat_beentry() but with locally computed additions (like
|
||||
* xid and xmin values of the backend)
|
||||
* Like pgstat_get_beentry_by_backend_id() but with locally computed additions
|
||||
* (like xid and xmin values of the backend)
|
||||
*
|
||||
* The beid argument is a 1-based index in the localBackendStatusTable
|
||||
* (note that this is unlike pgstat_fetch_stat_beentry()).
|
||||
* The idx argument is a 1-based index in the localBackendStatusTable
|
||||
* (note that this is unlike pgstat_get_beentry_by_backend_id()).
|
||||
* Returns NULL if the argument is out of range (no current caller does that).
|
||||
*
|
||||
* NB: caller is responsible for a check if the user is permitted to see
|
||||
@@ -1125,14 +1125,14 @@ pgstat_fetch_stat_beentry(BackendId beid)
|
||||
* ----------
|
||||
*/
|
||||
LocalPgBackendStatus *
|
||||
pgstat_fetch_stat_local_beentry(int beid)
|
||||
pgstat_get_local_beentry_by_index(int idx)
|
||||
{
|
||||
pgstat_read_current_status();
|
||||
|
||||
if (beid < 1 || beid > localNumBackends)
|
||||
if (idx < 1 || idx > localNumBackends)
|
||||
return NULL;
|
||||
|
||||
return &localBackendStatusTable[beid - 1];
|
||||
return &localBackendStatusTable[idx - 1];
|
||||
}
|
||||
|
||||
|
||||
@@ -1141,7 +1141,7 @@ pgstat_fetch_stat_local_beentry(int beid)
|
||||
*
|
||||
* Support function for the SQL-callable pgstat* functions. Returns
|
||||
* the number of sessions known in the localBackendStatusTable, i.e.
|
||||
* the maximum 1-based index to pass to pgstat_fetch_stat_local_beentry().
|
||||
* the maximum 1-based index to pass to pgstat_get_local_beentry_by_index().
|
||||
* ----------
|
||||
*/
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user