From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Datum as struct |
Date: | 2025-07-31 14:02:35 |
Message-ID: | 8246d7ff-f4b7-4363-913e-827dadfeb145@eisentraut.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Another draft patch set that I had lying around that was mentioned in [0].
The idea is to change Datum to a struct so that you can no longer rely
on it being implicitly convertable to other C types, which enforces use
of proper DatumGet*() and *GetDatum() functions, which might ultimately
help with portability and robustness and the like. (An alternative idea
is to make Datum a union so that you don't need so many casts to begin
with. But this has a lot of the same issues, so it can be considered
implicitly here.)
The first three patches clean up the use of the conversion functions.
Some are missing, some are superfluous, some are used the wrong way
around (!!).
The fourth patch tidies up the use of varatt.h macros. These should
arguably not be used on Datum values but instead be converted with
DatumGetPointer(). This is very similar to the patch that I also
included in the thread "Convert varatt.h macros to static inline
functions" that I just posted.
The fifth patch cleans up some untidy use of hash functions with the
wrong argument type.
The last patch is the actual conversion. As you can see there, and as
was also mentioned in [0], it's quite a bit of churn. I'm not seriously
proposing it at this point, but maybe it can serve as a guide for
refactoring some of the interfaces to make the impact smaller, or
something like that.
But I think the patches 0001 through 0005 are useful now.
I tested this against the original patch in [0]. It fixes some of the
issues discussed there but not all of them.
[0]:
https://www.postgresql.org/message-id/flat/1749799.1752797397%40sss.pgh.pa.us
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Fix-mixups-of-FooGetDatum-vs.-DatumGetFoo.patch | text/plain | 4.4 KB |
v1-0002-Remove-useless-superfluous-Datum-conversions.patch | text/plain | 9.8 KB |
v1-0003-Add-missing-Datum-conversions.patch | text/plain | 41.1 KB |
v1-0004-Fix-varatt-versus-Datum-type-confusions.patch | text/plain | 19.3 KB |
v1-0005-Fix-various-hash-function-uses.patch | text/plain | 4.0 KB |
v1-0006-WIP-Datum-as-struct.patch | text/plain | 289.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Luzanov | 2025-07-31 14:05:19 | Re: Eagerly scan all-visible pages to amortize aggressive vacuum |
Previous Message | Christoph Berg | 2025-07-31 13:52:36 | Re: Non-text mode for pg_dumpall |