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

From Bharath Rupireddy
Subject Replace pg_controldata output fields with macros for better code manageability
Date
Msg-id CALj2ACUhQHBvHpt_=NGbbX=4Hu87c_9KEu5h5yQEqA04cyJ=TQ@mail.gmail.com
Whole thread Raw
Responses Re: Replace pg_controldata output fields with macros for better code manageability
Re: Replace pg_controldata output fields with macros for better code manageability
List pgsql-hackers
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.

Regards,
Bharath Rupireddy.



pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Remove extra includes of "access/xloginsert.h" when "access/xlog.h" is included
Next
From: Bharath Rupireddy
Date:
Subject: Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?