Re: [PATCH] add relation and block-level filtering to pg_waldump - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [PATCH] add relation and block-level filtering to pg_waldump
Date
Msg-id d51b7a33-9662-0af5-5061-114defb1d5fb@enterprisedb.com
Whole thread Raw
In response to Re: [PATCH] add relation and block-level filtering to pg_waldump  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: [PATCH] add relation and block-level filtering to pg_waldump  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
List 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?



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Documenting when to retry on serialization failure
Next
From: Simon Riggs
Date:
Subject: Re: Reducing power consumption on idle servers