From f26b35b30c0b4869f17443198a44ad01ede845c0 Mon Sep 17 00:00:00 2001 From: Roshan Kanwar Date: Mon, 28 Oct 2024 15:09:50 +0000 Subject: [PATCH] BABEL: Fixes after community commit 024c521117 Signed-off-by: Roshan Kanwar --- src/backend/catalog/storage.c | 4 +-- src/backend/utils/activity/backend_status.c | 30 ++++++++++----------- src/backend/utils/adt/pgstatfuncs.c | 4 +-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c index 269e4b3ef7d..8f433b3a04d 100644 --- a/src/backend/catalog/storage.c +++ b/src/backend/catalog/storage.c @@ -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; @@ -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; diff --git a/src/backend/utils/activity/backend_status.c b/src/backend/utils/activity/backend_status.c index c91ed5a4b64..5bd3942646d 100644 --- a/src/backend/utils/activity/backend_status.c +++ b/src/backend/utils/activity/backend_status.c @@ -118,7 +118,7 @@ CreateSharedBackendStatus(void) { Size size; bool found; - int i; + ProcNumber procNumber; char *buffer; /* Create or attach to the shared array */ @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; @@ -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 @@ -964,7 +963,6 @@ const char * pgstat_get_crashed_backend_activity(int pid, char *buffer, int buflen) { volatile PgBackendStatus *beentry; - int i; beentry = BackendStatusArray; @@ -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) { @@ -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()). @@ -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; @@ -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 diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 4c8a761f26f..2cdb09ee39a 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -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())