Skip to content

Commit

Permalink
BABEL: Fixes after community commit 024c521117
Browse files Browse the repository at this point in the history
Signed-off-by: Roshan Kanwar <[email protected]>
  • Loading branch information
roshan0708 committed Oct 28, 2024
1 parent 6d10a3c commit f26b35b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/backend/catalog/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ RelationCreateStorage(RelFileLocator rlocator, char relpersistence,
break;
case RELPERSISTENCE_UNLOGGED:
procNumber = INVALID_PROC_NUMBER;
needs_wal = false;
needs_wal = true;
break;
case RELPERSISTENCE_PERMANENT:
procNumber = INVALID_PROC_NUMBER;
Expand Down Expand Up @@ -229,7 +229,7 @@ RelationDropStorage(Relation rel)
pending = (PendingRelDelete *)
MemoryContextAlloc(TopMemoryContext, sizeof(PendingRelDelete));
pending->rlocator = rel->rd_locator;
pending->backend = rel->rd_backend;
pending->procNumber = rel->rd_backend;
pending->atCommit = false;
pending->nestLevel = GetCurrentTransactionNestLevel();
pending->next = pendingDeletes;
Expand Down
30 changes: 14 additions & 16 deletions src/backend/utils/activity/backend_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ CreateSharedBackendStatus(void)
{
Size size;
bool found;
int i;
ProcNumber procNumber;
char *buffer;

/* Create or attach to the shared array */
Expand All @@ -145,9 +145,9 @@ CreateSharedBackendStatus(void)

/* Initialize st_appname pointers. */
buffer = BackendAppnameBuffer;
for (i = 0; i < NumBackendStatSlots; i++)
for (procNumber = 0; procNumber < NumBackendStatSlots; procNumber++)
{
BackendStatusArray[i].st_appname = buffer;
BackendStatusArray[procNumber].st_appname = buffer;
buffer += NAMEDATALEN;
}
}
Expand All @@ -163,9 +163,9 @@ CreateSharedBackendStatus(void)

/* Initialize st_clienthostname pointers. */
buffer = BackendClientHostnameBuffer;
for (i = 0; i < NumBackendStatSlots; i++)
for (procNumber = 0; procNumber < NumBackendStatSlots; procNumber++)
{
BackendStatusArray[i].st_clienthostname = buffer;
BackendStatusArray[procNumber].st_clienthostname = buffer;
buffer += NAMEDATALEN;
}
}
Expand All @@ -184,9 +184,9 @@ CreateSharedBackendStatus(void)

/* Initialize st_activity pointers. */
buffer = BackendActivityBuffer;
for (i = 0; i < NumBackendStatSlots; i++)
for (procNumber = 0; procNumber < NumBackendStatSlots; procNumber++)
{
BackendStatusArray[i].st_activity_raw = buffer;
BackendStatusArray[procNumber].st_activity_raw = buffer;
buffer += pgstat_track_activity_query_size;
}
}
Expand Down Expand Up @@ -832,7 +832,7 @@ pgstat_read_current_status(void)
/*
* The BackendStatusArray index is exactly the ProcNumber of the
* source backend. Note that this means localBackendStatusTable
* is in order by proc_number. pgstat_get_beentry_by_backend_id()
* is in order by proc_number. pgstat_get_beentry_by_proc_number()
* depends on that.
*/
localentry->proc_number = procNumber;
Expand Down Expand Up @@ -886,10 +886,9 @@ const char *
pgstat_get_backend_current_activity(int pid, bool checkUser)
{
PgBackendStatus *beentry;
int i;

beentry = BackendStatusArray;
for (i = 1; i <= MaxBackends; i++)
for (ProcNumber p = 0; p < MaxBackends; p++)
{
/*
* Although we expect the target backend's entry to be stable, that
Expand Down Expand Up @@ -964,7 +963,6 @@ const char *
pgstat_get_crashed_backend_activity(int pid, char *buffer, int buflen)
{
volatile PgBackendStatus *beentry;
int i;

beentry = BackendStatusArray;

Expand All @@ -975,7 +973,7 @@ pgstat_get_crashed_backend_activity(int pid, char *buffer, int buflen)
if (beentry == NULL || BackendActivityBuffer == NULL)
return NULL;

for (i = 1; i <= MaxBackends; i++)
for (ProcNumber p = 0; p < MaxBackends; p++)
{
if (beentry->st_procpid == pid)
{
Expand Down Expand Up @@ -1060,7 +1058,7 @@ cmp_lbestatus(const void *a, const void *b)
*
* 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.
* or NULL if the given procno doesn't identify any known session.
*
* The argument is the ProcNumber of the desired session
* (note that this is unlike pgstat_get_local_beentry_by_index()).
Expand All @@ -1074,7 +1072,7 @@ pgstat_get_beentry_by_proc_number(ProcNumber procNumber)
{
LocalPgBackendStatus *ret = pgstat_get_local_beentry_by_proc_number(procNumber);

if (ret)
if (ret && ret->backendStatus.st_procpid > 0)
return &ret->backendStatus;

return NULL;
Expand Down Expand Up @@ -1114,11 +1112,11 @@ pgstat_get_local_beentry_by_proc_number(ProcNumber procNumber)
/* ----------
* pgstat_get_local_beentry_by_index() -
*
* Like pgstat_get_beentry_by_backend_id() but with locally computed additions
* Like pgstat_get_beentry_by_proc_number() but with locally computed additions
* (like xid and xmin values of the backend)
*
* The idx argument is a 1-based index in the localBackendStatusTable
* (note that this is unlike pgstat_get_beentry_by_backend_id()).
* (note that this is unlike pgstat_get_beentry_by_proc_number()).
* 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
Expand Down
4 changes: 2 additions & 2 deletions src/backend/utils/adt/pgstatfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
* We recheck pgstat_fetch_stat_numbackends() each time through, just in
* case the local status data has been refreshed since we started. It's
* plenty cheap enough if not. If a refresh does happen, we'll likely
* miss or duplicate some backend IDs, but we're content not to crash.
* miss or duplicate some proc numbers, but we're content not to crash.
* (Refreshing midway through such a query would be problematic usage
* anyway, since the backend IDs we've already returned might no longer
* anyway, since the proc numbers we've already returned might no longer
* refer to extant sessions.)
*/
if (fctx[0] <= pgstat_fetch_stat_numbackends())
Expand Down

0 comments on commit f26b35b

Please sign in to comment.