Skip to content

Commit 1ecd035

Browse files
Jan WieckJan Wieck
authored andcommitted
Added hints about the reason, why the command string in
the view pg_stat_activity is missing, as per Bruces suggestion. Jan
1 parent c3c09be commit 1ecd035

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,24 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
286286
PgStat_StatBeEntry *beentry;
287287
int32 beid;
288288
int len;
289+
char *activity;
289290
text *result;
290291

291292
beid = PG_GETARG_INT32(0);
292293

293294
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
294-
PG_RETURN_NULL();
295-
296-
if (!superuser() && beentry->userid != GetUserId())
297-
PG_RETURN_NULL();
295+
activity = "<backend information not available>";
296+
else if (!superuser() && beentry->userid != GetUserId())
297+
activity = "<insufficient privilege>";
298+
else if (*(beentry->activity) == '\0')
299+
activity = "<command string not enabled>";
300+
else
301+
activity = beentry->activity;
298302

299-
len = strlen(beentry->activity);
303+
len = strlen(activity);
300304
result = palloc(VARHDRSZ + len);
301305
VARATT_SIZEP(result) = VARHDRSZ + len;
302-
memcpy(VARDATA(result), beentry->activity, len);
306+
memcpy(VARDATA(result), activity, len);
303307

304308
PG_RETURN_TEXT_P(result);
305309
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy