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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to