Re: Convert varatt.h macros to static inline functions

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Convert varatt.h macros to static inline functions
Date: 2025-07-31 23:40:33
Message-ID: aIv-8dE7MMp6nn0z@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 31, 2025 at 10:06:02AM -0400, Tom Lane wrote:
> Peter Eisentraut <peter(at)eisentraut(dot)org> writes:
> > I had this lying around as a draft patch, as part of my ongoing campaign
> > to convert many complicated macros to static inline functions. Since
> > the topic was mentioned in another thread [0], I cleaned up the patch so
> > that we can all look at it.
>
> I had just finished doing exactly that, per my idea in the other
> thread of providing both pointer and Datum variants where needed.
> I'll look more closely at yours in a bit, but here's mine.

I'm finding that your wip version is bit more complete as you have
introduced inline functions for these ones:
- VARATT_EXTERNAL_GET_EXTSIZE()
- VARATT_EXTERNAL_GET_COMPRESS_METHOD().

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? There is a bit of chaos
that has accumulated in varatt.h over the ages, still there is a
hierarchy with the most "internal" structures and what gets used by
the code C code. So we could use this occasion to split things if
that brings some clarity..
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2025-08-01 00:03:21 Re: Assertion failure in pgbench
Previous Message Japin Li 2025-07-31 23:34:12 Re: log_min_messages per backend type