Re: Remove nonmeaningful prefixes in PgStat_* fields - Mailing list pgsql-hackers

From Melanie Plageman
Subject Re: Remove nonmeaningful prefixes in PgStat_* fields
Date
Msg-id 20230322185223.gxppwjajvvbtx7m6@liskov
Whole thread Raw
In response to Re: Remove nonmeaningful prefixes in PgStat_* fields  ("Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>)
Responses Re: Remove nonmeaningful prefixes in PgStat_* fields  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On Mon, Mar 20, 2023 at 10:05:21AM +0100, Drouvot, Bertrand wrote:
> Hi,
> 
> On 3/20/23 8:32 AM, Michael Paquier wrote:
> > 
> >          /* Total time previously charged to function, as of function start */
> > -       instr_time      save_f_total_time;
> > +       instr_time      save_total_time;
> > I have something to say about this one, though..  I find this change a
> > bit confusing.  It may be better kept as it is, or I think that we'd
> > better rename also "save_total" and "start" to reflect in a better way
> > what they do, because removing "f_" reduces the meaning of the field
> > with the two others in the same structure.
> 
> Thanks for looking at it!
> 
> Good point and keeping it as it is currently would not
> affect the work that is/will be done in [1].
> 
> So, please find attached V2 attached taking this comment into account.

> diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
> index 35c6d46555..4f21fb2dc2 100644
> --- a/src/backend/utils/adt/pgstatfuncs.c
> +++ b/src/backend/utils/adt/pgstatfuncs.c
> @@ -1552,7 +1552,7 @@ pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
>          result = 0;
>      else
>      {
> -        result = tabentry->t_counts.t_tuples_inserted;
> +        result = tabentry->counts.tuples_inserted;

This comment still has the t_ prefix as does the one for tuples_updated
and deleted.

otherwise, LGTM.

>          /* live subtransactions' counts aren't in t_tuples_inserted yet */
>          for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
>              result += trans->tuples_inserted;
> @@ -1573,7 +1573,7 @@ pg_stat_get_xact_tuples_updated(PG_FUNCTION_ARGS)
>          result = 0;
>      else
>      {
> -        result = tabentry->t_counts.t_tuples_updated;
> +        result = tabentry->counts.tuples_updated;
>          /* live subtransactions' counts aren't in t_tuples_updated yet */
>          for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
>              result += trans->tuples_updated;
> @@ -1594,7 +1594,7 @@ pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
>          result = 0;
>      else
>      {
> -        result = tabentry->t_counts.t_tuples_deleted;
> +        result = tabentry->counts.tuples_deleted;
>          /* live subtransactions' counts aren't in t_tuples_deleted yet */
>          for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
>              result += trans->tuples_deleted;
> @@ -1613,7 +1613,7 @@ pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS)
>      if ((tabentry = find_tabstat_entry(relid)) == NULL)
>          result = 0;
>      else
> -        result = (int64) (tabentry->t_counts.t_tuples_hot_updated);
> +        result = (int64) (tabentry->counts.tuples_hot_updated);
>  
>      PG_RETURN_INT64(result);
>  }

- Melanie



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Request for comment on setting binary format output per session
Next
From: Andres Freund
Date:
Subject: Re: meson documentation build open issues