/*
* 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,
}
/* ----------
- * 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;
/* ----------
- * 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
* ----------
*/
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];
}
*
* 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
if (fctx[0] <= pgstat_fetch_stat_numbackends())
{
/* do when there is more left to send */
- LocalPgBackendStatus *local_beentry = pgstat_fetch_stat_local_beentry(fctx[0]);
+ LocalPgBackendStatus *local_beentry = pgstat_get_local_beentry_by_index(fctx[0]);
SRF_RETURN_NEXT(funcctx, Int32GetDatum(local_beentry->backend_id));
}
bool nulls[PG_STAT_GET_PROGRESS_COLS] = {0};
int i;
- local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
+ local_beentry = pgstat_get_local_beentry_by_index(curr_backend);
beentry = &local_beentry->backendStatus;
/*
const char *wait_event = NULL;
/* Get the next one in the list */
- local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
+ local_beentry = pgstat_get_local_beentry_by_index(curr_backend);
beentry = &local_beentry->backendStatus;
/* If looking for specific PID, ignore all the others */
int32 beid = PG_GETARG_INT32(0);
PgBackendStatus *beentry;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
PG_RETURN_INT32(beentry->st_procpid);
int32 beid = PG_GETARG_INT32(0);
PgBackendStatus *beentry;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
PG_RETURN_OID(beentry->st_databaseid);
int32 beid = PG_GETARG_INT32(0);
PgBackendStatus *beentry;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
PG_RETURN_OID(beentry->st_userid);
BlessTupleDesc(tupdesc);
- if ((local_beentry = pgstat_fetch_stat_local_beentry(beid)) != NULL)
+ if ((local_beentry = pgstat_get_local_beentry_by_index(beid)) != NULL)
{
/* Fill values and NULLs */
values[0] = Int32GetDatum(local_beentry->backend_subxact_count);
char *clipped_activity;
text *ret;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
activity = "<backend information not available>";
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
activity = "<insufficient privilege>";
PGPROC *proc;
const char *wait_event_type = NULL;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
wait_event_type = "<backend information not available>";
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
wait_event_type = "<insufficient privilege>";
PGPROC *proc;
const char *wait_event = NULL;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
wait_event = "<backend information not available>";
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
wait_event = "<insufficient privilege>";
TimestampTz result;
PgBackendStatus *beentry;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
TimestampTz result;
PgBackendStatus *beentry;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
TimestampTz result;
PgBackendStatus *beentry;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
char remote_host[NI_MAXHOST];
int ret;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
char remote_port[NI_MAXSERV];
int ret;
- if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ if ((beentry = pgstat_get_beentry_by_backend_id(beid)) == NULL)
PG_RETURN_NULL();
else if (!HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
Oid dbid = PG_GETARG_OID(0);
int32 result;
int tot_backends = pgstat_fetch_stat_numbackends();
- int beid;
+ int idx;
result = 0;
- for (beid = 1; beid <= tot_backends; beid++)
+ for (idx = 1; idx <= tot_backends; idx++)
{
- LocalPgBackendStatus *local_beentry = pgstat_fetch_stat_local_beentry(beid);
+ LocalPgBackendStatus *local_beentry = pgstat_get_local_beentry_by_index(idx);
if (local_beentry->backendStatus.st_databaseid == dbid)
result++;