| From: | David Geier <geidav(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Change copyObject() to use typeof_unqual |
| Date: | 2026-01-20 10:48:00 |
| Message-ID: | fc82531a-2fd0-470d-89df-3a305a3fb476@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Peter!
On 20.01.2026 10:37, Peter Eisentraut wrote:
> Currently, when the argument of copyObject() is const-qualified, the
> return type is also, because the use of typeof carries over all the
> qualifiers. This is incorrect, since the point of copyObject() is to
> make a copy to mutate. But apparently no code ran into it.
Great change. I've ran into that multiple times and had to
un-const-correct my code because of how copyObject() works.
> The new implementation uses typeof_unqual, which drops the qualifiers,
> making this work correctly.
>
> typeof_unqual is standardized in C23, but all recent versions of all the
> usual compilers support it even in non-C23 mode, at least as
> __typeof_unqual__. We add a configure/meson test for typeof_unqual and
> __typeof_unqual__ and use it if it's available, else we use the existing
> fallback of just returning void *.
>
> (Even MSVC supports it, if we use a slightly newer version than is on
> CI. For example, the new buildfarm member unicorn would support it.)
I'm not too familiar with the build system, so I let someone else review
this part.
> The second patch make some changes to take advantage of this improved
> qualifier handling. EventTriggerCollectSimpleCommand() is a good
> example: It takes a node tree and makes a copy that it keeps around for
> its internal purposes, but it can't communicate via its function
> signature that it promises not scribble on the passed node tree. That
> is now fixed.
The changes to EvenTriggerCollectSimpleCommand() look good to me.
Are you planning to look at the rest of the code as well? At a quick
glance there seem to be more places that can be changed in similar ways,
e.g. see refresh_matview_datafill().
--
David Geier
| From | Date | Subject | |
|---|---|---|---|
| Next Message | lakshmi | 2026-01-20 10:51:14 | Re: Proposal: Adding compression of temporary files |
| Previous Message | Christoph Berg | 2026-01-20 10:46:25 | Re: Optional skipping of unchanged relations during ANALYZE? |