Convert varatt.h macros to static inline functions

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Convert varatt.h macros to static inline functions
Date: 2025-07-31 13:08:13
Message-ID: 928ea48f-77c6-417b-897c-621ef16685a6@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

The titular change is to convert the macros in varatt.h to inline
functions, so they are easier to read and use. I only touched the ones
for external use, not the internal ones, mainly because I don't have a
way to test a big-endian build.

Part of the change is also figuring out exactly what the argument and
return types should be. In many cases, there were some inconsistencies,
because the macros would just cast anything you give them into the shape
they want, no matter whether it makes sense. In particular, the callers
were inconsistent about whether macros like VARDATA() and VARSIZE()
should take struct varlena or Datum, or I guess both. I cleaned this up
by adding the required DatumGetPointer() calls in the first patch. The
thread [0] is now discussing some other ideas, but this is what I had,
and this way it's at least consistent with other existing code.

[0]:
https://www.postgresql.org/message-id/flat/1749799.1752797397%40sss.pgh.pa.us

Attachment Content-Type Size
v1-0001-Fix-varatt-versus-Datum-type-confusions.patch text/plain 21.6 KB
v1-0002-Convert-varatt.h-macros-to-static-inline-function.patch text/plain 10.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2025-07-31 13:31:03 Re: Eagerly scan all-visible pages to amortize aggressive vacuum
Previous Message wenhui qiu 2025-07-31 12:49:38 Re: Pathify RHS unique-ification for semijoin planning