Re: pg_resetwal: Fix wrong directory in log output - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: pg_resetwal: Fix wrong directory in log output
Date
Msg-id 20260203.112541.1322541369423234463.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: pg_resetwal: Fix wrong directory in log output  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: pg_resetwal: Fix wrong directory in log output
List pgsql-hackers
Hello.

At Tue, 3 Feb 2026 10:13:53 +0800, Chao Li <li.evan.chao@gmail.com> wrote in 
> The patch is straightforward and looks correct.

Indeed, it does.

However, the scoping of the define symbols in this file seems somewhat
confused.

For example:

>   static void
>   KillExistingArchiveStatus(void)
>   {
>   #define ARCHSTATDIR XLOGDIR "/archive_status"

This define was presumably intended to be used only within the function,
but since it is a macro, it can also be used from other functions, which
appears to have contributed to this mistake.

It would be better to clearly distinguish between file-scoped symbols
and function-scoped ones. For function-local constants like this,
using a 'static const char[] instead of a macro would make the
intended scope explicit and help prevent similar issues.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Corey Huinker
Date:
Subject: Re: Add expressions to pg_restore_extended_stats()
Next
From: Peter Smith
Date:
Subject: Re: use the malloc macros in pg_dump.c