Re: Convert *GetDatum() and DatumGet*() macros to inline functions

Aleksander Alekseev <aleksander@timescale.com>

From: Aleksander Alekseev <aleksander@timescale.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-09-05T14:20:03Z
Lists: pgsql-hackers
Hi Peter,

> Which compiler is that, by the way?

The warnings were reported by cfbot during the "clang_warning" step.
According to the logs:

```
using compiler=Debian clang version 11.0.1-2
```

Personally I use Clang 14 on MacOS and I don't get these warnings.

> I think to resolve that we could either
>
> 1. Not define PointerGetDatum() with a const argument, and just sprinkle
> in a few unconstify calls where necessary.
>
> 2. Maybe add a NonconstPointerGetDatum() for those few cases where
> pointer arguments are used for return values.
>
> 3. Go with your patch and just fix up the warnings about uninitialized
> variables.  But that seems the least principled to me.

IMO the 3rd option is the lesser evil. Initializing four bools/ints in
order to make Clang 11 happy doesn't strike me as such a big deal. At
least until somebody reports a bottleneck for this particular reason.
We can optimize the code when and if this will happen.

-- 
Best regards,
Aleksander Alekseev



Commits

  1. Convert *GetDatum() and DatumGet*() macros to inline functions

  2. Fix incorrect uses of Datum conversion macros