File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -286,20 +286,24 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
286
286
PgStat_StatBeEntry * beentry ;
287
287
int32 beid ;
288
288
int len ;
289
+ char * activity ;
289
290
text * result ;
290
291
291
292
beid = PG_GETARG_INT32 (0 );
292
293
293
294
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 ;
298
302
299
- len = strlen (beentry -> activity );
303
+ len = strlen (activity );
300
304
result = palloc (VARHDRSZ + len );
301
305
VARATT_SIZEP (result ) = VARHDRSZ + len ;
302
- memcpy (VARDATA (result ), beentry -> activity , len );
306
+ memcpy (VARDATA (result ), activity , len );
303
307
304
308
PG_RETURN_TEXT_P (result );
305
309
}
You can’t perform that action at this time.
0 commit comments