Re: Replace pg_controldata output fields with macros for better code manageability - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Replace pg_controldata output fields with macros for better code manageability
Date
Msg-id YfsNj+FOz9669xVd@momjian.us
Whole thread Raw
In response to Replace pg_controldata output fields with macros for better code manageability  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Replace pg_controldata output fields with macros for better code manageability  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
On Sat, Jan 29, 2022 at 08:00:53PM +0530, Bharath Rupireddy wrote:
> Hi,
> 
> While working on another pg_control patch, I observed that the
> pg_controldata output fields such as "Latest checkpoint's
> TimeLineID:", "Latest checkpoint's NextOID:'' and so on, are being
> used in pg_resetwal.c, pg_controldata.c and pg_upgrade/controldata.c.
> Direct usage of these fields in many places doesn't look good and can
> be error prone if we try to change the text in one place and forget in
> another place. I'm thinking of having those fields as macros in
> pg_control.h, something like [1] and use it all the places. This will
> be a good idea for better code manageability IMO.
> 
> Thoughts?
> 
> [1]
> #define PG_CONTROL_FIELD_VERSION_NUMBER "pg_control version number:"
> #define PG_CONTROL_FIELD_CATALOG_NUMBER "Catalog version number:"
> #define PG_CONTROL_FIELD_CHECKPOINT_TLI "Latest checkpoint's TimeLineID:"
> #define PG_CONTROL_FIELD_CHECKPOINT_PREV_TLI "Latest checkpoint's
> PrevTimeLineID:"
> #define PG_CONTROL_FIELD_CHECKPOINT_OLDESTXID "Latest checkpoint's oldestXID:"
> #define PG_CONTROL_FIELD_CHECKPOINT_OLDESTXID_DB "Latest checkpoint's
> oldestXID's DB:"
> and so on.

That seems like a very good idea.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  If only the physical world exists, free will is an illusion.




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Server-side base backup: why superuser, not pg_write_server_files?
Next
From: Peter Smith
Date:
Subject: Re: row filtering for logical replication