Re: Convert varatt.h macros to static inline functions

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-01T05:07:33Z
Lists: pgsql-hackers
Michael Paquier <michael@paquier.xyz> writes:
> Another comment that can apply to all the patches presented on this
> thread.  Could it be worth splitting these inline functions into a
> separate header that declares varatt.h, meaning that we'd need to
> think a bit more about the structures themselves and all the
> sub-macros like SET_VARSIZE_1B() & friends?

IIRC we already moved these macros out of postgres.h, some years ago.

I don't really see how we could hide the lower-level macros from
callers' eyes while still having them available to inline functions.
The point of this exercise IMO is not information hiding: it is to
be clearer about the input and output datatypes of the functions,
and to eliminate multiple-evaluation hazards.

			regards, tom lane



Commits

  1. Suppress maybe-uninitialized warning.

  2. Convert varatt.h access macros to static inline functions.

  3. Fix varatt versus Datum type confusions