Convert varatt.h macros to static inline functions
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-07-31T13:08:13Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fix-varatt-versus-Datum-type-confusions.patch (text/plain) patch v1-0001
- v1-0002-Convert-varatt.h-macros-to-static-inline-function.patch (text/plain) patch v1-0002
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
Commits
-
Suppress maybe-uninitialized warning.
- b5c53b403c93 19 (unreleased) landed
-
Convert varatt.h access macros to static inline functions.
- e035863c9a04 19 (unreleased) landed
-
Fix varatt versus Datum type confusions
- 0f5ade7a367c 19 (unreleased) landed