Re: get rid of Pointer type, mostly

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: get rid of Pointer type, mostly
Date: 2025-11-24 14:54:01
Message-ID: aSRxiScuxPJ2bD1A@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Nov 24, 2025 at 11:20:56AM +0100, Peter Eisentraut wrote:
> In a previous thread[0], the question was asked, 'Why do we bother with a
> "Pointer" type?'. So I looked into get rid of it.
>
> There are two stages to this. One is changing all code that wants to do
> pointer arithmetic to use char * instead of relying on Pointer being char *.
> Then we can change Pointer to be void * and remove a bunch of casts.
>
> The second is getting rid of uses of Pointer for variables where you might
> as well use void * directly. These are actually not that many.
>
> This gets rid of all uses, except in the GIN code, which is full of Pointer
> use, and it's part of the documented API. I'm not touching that, not least
> because this kind of code
>
> Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
>
> needs more brain-bending to understand that I'm prepared to spend. So as
> far as I'm concerned, the pointer type can continue to exist as a curiosity
> of the GIN API, but in all other places, it wasn't really doing much of
> anything anyway.

The patch series is very easy to follow, thanks! I agree with the idea: we now
use (char *) for byte(s) manipulation and (void *) for generic pointer usage.

I checked the changes and if any have been missed and that looks ok to me.

Just a nit, while at it, maybe we could get rid of those extra parentheses:

@@ -140,20 +140,20 @@ GinDataLeafPageGetItems(Page page, int *nitems, ItemPointerData advancePast)
{
GinPostingList *seg = GinDataLeafPageGetPostingList(page);
Size len = GinDataLeafPageGetPostingListSize(page);
- Pointer endptr = ((Pointer) seg) + len;
+ char *endptr = ((char *) seg) + len;

The other existing ones in some macros are good to keep.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2025-11-24 15:00:04 Re: backend/nodes cleanup: Move loop variables definitions into for statement
Previous Message Daniel Gustafsson 2025-11-24 14:53:31 Re: Serverside SNI support in libpq