Re: Patch: show xid and xmin in pg_stat_activity and pg_stat_replication

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Christian Kruse <christian(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Subject: Re: Patch: show xid and xmin in pg_stat_activity and pg_stat_replication
Date: 2014-02-21 12:49:37
Message-ID: 20140221124937.GA28858@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-02-21 13:40:59 +0100, Christian Kruse wrote:
> diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
> index a4f31cf..e65b079 100644
> --- a/src/backend/utils/adt/pgstatfuncs.c
> +++ b/src/backend/utils/adt/pgstatfuncs.c
> @@ -536,7 +536,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
>
> oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
>
> - tupdesc = CreateTemplateTupleDesc(14, false);
> + tupdesc = CreateTemplateTupleDesc(16, false);
> TupleDescInitEntry(tupdesc, (AttrNumber) 1, "datid",
> OIDOID, -1, 0);
> TupleDescInitEntry(tupdesc, (AttrNumber) 2, "pid",
> @@ -565,6 +565,10 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
> TEXTOID, -1, 0);
> TupleDescInitEntry(tupdesc, (AttrNumber) 14, "client_port",
> INT4OID, -1, 0);
> + TupleDescInitEntry(tupdesc, (AttrNumber) 15, "backend_xid",
> + XIDOID, -1, 0);
> + TupleDescInitEntry(tupdesc, (AttrNumber) 16, "backend_xmin",
> + XIDOID, -1, 0);
>
> funcctx->tuple_desc = BlessTupleDesc(tupdesc);
>
> @@ -588,11 +592,11 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
>
> for (i = 1; i <= n; i++)
> {
> - PgBackendStatus *be = pgstat_fetch_stat_beentry(i);
> + LocalPgBackendStatus *be = pgstat_fetch_stat_local_beentry(i);
>
> if (be)
> {
> - if (be->st_procpid == pid)
> + if (be->backendStatus.st_procpid
> == pid)

If we're going this route - which I am ok with - I'd suggest for doing
something like:

> - PgBackendStatus *be = pgstat_fetch_stat_beentry(i);
> + LocalPgBackendStatus *lbe = pgstat_fetch_stat_local_beentry(i);
> + PgBackendStatus *be = &lb->backendStatus;

There seems little point in making all those lines longer and the
accompanying diff noise if all it costs is a local variable.

Makes sense?

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Szymon Guz 2014-02-21 12:53:01 Re: Storing the password in .pgpass file in an encrypted format
Previous Message firoz e v 2014-02-21 12:49:26 Storing the password in .pgpass file in an encrypted format