Re: Replace pg_controldata output fields with macros for better code manageability

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Replace pg_controldata output fields with macros for better code manageability
Date: 2022-02-03 13:51:24
Message-ID: d0b0fa85-4fe9-7d0c-c74c-18141bc8aab5@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29.01.22 15:30, Bharath Rupireddy wrote:
> 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.

The duplication between pg_resetwal and pg_controldata could probably be
handled by refactoring the code so that only one place is responsible
for printing it. The usages in pg_upgrade are probably best guarded by
tests that ensure that any changes anywhere else don't break things.
Using macros like you suggest only protects against one kind of change:
changing the wording of a line. But it doesn't protect for example
against a line being removed from the output.

While I'm sympathetic to the issue you describe, the proposed solution
introduces a significant amount of ugliness for a problem that is really
quite rare.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-02-03 13:54:15 Re: psql - add SHOW_ALL_RESULTS option
Previous Message Bharath Rupireddy 2022-02-03 13:10:55 Re: pg_receivewal - couple of improvements