Re: log_hostname and pg_stat_activity - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: log_hostname and pg_stat_activity
Date
Msg-id 1295296247-sup-6397@alvh.no-ip.org
Whole thread Raw
In response to Re: log_hostname and pg_stat_activity  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Excerpts from Peter Eisentraut's message of sáb ene 15 13:15:45 -0300 2011:

> Here is a patch that adds a client_hostname field to pg_stat_activity.
> It takes the hostname if it is available either by having log_hostname
> set or if the pg_hba.conf processing resolved it.  So I think for most
> people who would care about this thing, it would "just work".
> 
> I'm not so sure about the pgstat.c internals.  Do we need the separate
> buffer in shared memory, as in this patch, or could we just copy the
> name directly into the PgBackendStatus struct?  I guess not the latter,
> since my compiler complains about copying a string into a volatile
> pointer.

I think you should do it like clientaddr is handled: fill a string with
the value from MyProcPort, then make the PgBackendStatus point to that.

BTW you need to touch BackendStatusShmemSize if you change the routine
below that (but AFAIU that should be taken out).

...

I'm confused ... why isn't this code broken?  I don't understand why
isn't clientaddr clobbered the next time someone uses the stack space,
given that it's not allocated anywhere.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: texteq/byteaeq: avoid detoast [REVIEW]
Next
From: Tom Lane
Date:
Subject: Re: Bug in pg_describe_object, patch v2