Re: [PATCH] add relation and block-level filtering to pg_waldump

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] add relation and block-level filtering to pg_waldump
Date: 2022-03-24 10:57:56
Message-ID: d51b7a33-9662-0af5-5061-114defb1d5fb@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23.03.22 23:54, Thomas Munro wrote:
>> That's because ForkNum is a signed type. You will probably succeed if
>> you use "%d" instead.
>
> Erm, is that really OK? C says "Each enumerated type shall be
> compatible with char, a signed integer type, or an
> unsigned integer type. The choice of type is implementation-defined,
> but shall be capable of representing the values of all the members of
> the enumeration." It could even legally vary from enum to enum,
> though in practice most compilers probably just use ints all the time
> unless you use weird pragma pack incantation. Therefore I think you
> need an intermediate variable with the size and signedness matching the
> format string, if you're going to scanf directly into it, which
> David's V6 did.

An intermediate variable is probably the best way to avoid thinking
about this much more. ;-) But note that the committed patch uses a %u
format whereas the ForkNum enum is signed.

Btw., why the sscanf() instead of just strtol/stroul?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2022-03-24 10:58:57 Re: Reducing power consumption on idle servers
Previous Message Simon Riggs 2022-03-24 10:43:54 Re: Documenting when to retry on serialization failure