From: Jan Wieck Date: Thu, 12 Feb 2004 01:44:22 +0000 (+0000) Subject: Added hints about the reason, why the command string in X-Git-Tag: REL8_0_0BETA1~1204 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ecd035b318f949090be59d1e1826b3d0c8f03e9;p=postgresql Added hints about the reason, why the command string in the view pg_stat_activity is missing, as per Bruces suggestion. Jan --- diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 440783764a..03166eac48 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -286,20 +286,24 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS) PgStat_StatBeEntry *beentry; int32 beid; int len; + char *activity; text *result; beid = PG_GETARG_INT32(0); if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL) - PG_RETURN_NULL(); - - if (!superuser() && beentry->userid != GetUserId()) - PG_RETURN_NULL(); + activity = ""; + else if (!superuser() && beentry->userid != GetUserId()) + activity = ""; + else if (*(beentry->activity) == '\0') + activity = ""; + else + activity = beentry->activity; - len = strlen(beentry->activity); + len = strlen(activity); result = palloc(VARHDRSZ + len); VARATT_SIZEP(result) = VARHDRSZ + len; - memcpy(VARDATA(result), beentry->activity, len); + memcpy(VARDATA(result), activity, len); PG_RETURN_TEXT_P(result); }