From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: System username in pg_stat_activity |
Date: | 2024-02-16 20:51:29 |
Message-ID: | 20240216205129.zzl2o6xmrxh4kyqw@awork3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2024-02-16 21:41:41 +0100, Magnus Hagander wrote:
> > Maybe I am missing something, but why aren't we just getting the value from
> > the leader's entry, instead of copying it?
>
> The answer to that would be "because I didn't think of it" :)
:)
> Were you thinking of something like the attached?
> @@ -435,6 +438,22 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
> {
> values[29] = Int32GetDatum(leader->pid);
> nulls[29] = false;
> +
> + /*
> + * The authenticated user in a parallel worker is the same as the one in
> + * the leader, so look it up there.
> + */
> + if (leader->backendId)
> + {
> + LocalPgBackendStatus *leaderstat = pgstat_get_local_beentry_by_backend_id(leader->backendId);
> +
> + if (leaderstat->backendStatus.st_auth_method != uaReject && leaderstat->backendStatus.st_auth_method != uaImplicitReject)
> + {
> + nulls[31] = nulls[32] = false;
> + values[31] = CStringGetTextDatum(hba_authname(leaderstat->backendStatus.st_auth_method));
> + values[32] = CStringGetTextDatum(leaderstat->backendStatus.st_auth_identity);
> + }
> + }
Mostly, yes.
I only skimmed the patch, but it sure looks to me that we could end up with
none of the branches setting 31,32, so I think you'd have to make sure to
handle that case.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2024-02-16 20:54:25 | Re: LogwrtResult contended spinlock |
Previous Message | Andres Freund | 2024-02-16 20:45:17 | Re: System username in pg_stat_activity |