Re: Add const qualifiers to XLogRegister*() functions

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add const qualifiers to XLogRegister*() functions
Date: 2024-09-03 06:15:29
Message-ID: 482fcfe2-c7b3-4906-b6fb-5be1f039b868@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28.08.24 12:04, Aleksander Alekseev wrote:
> Hi,
>
>> On 04.10.23 16:37, Peter Eisentraut wrote:
>>> On 03.10.23 13:28, Aleksander Alekseev wrote:
>>>> While examining the code for similar places I noticed that the
>>>> following functions can also be const'ified:
>>
>>>> - XLogRegisterData (?)
>>>
>>> I don't think this would work, at least without further work elsewhere,
>>> because the data is stored in XLogRecData, which has no const handling.
>>
>> I got around to fixing this. Here is a patch. It allows removing a few
>> unconstify() calls, which is nice.
>
> LGTM.

committed

> Note that this may affect third-party code. IMO this is not a big deal
> in this particular case.

I don't think this will impact any third-party code. Only maybe for the
better, by being able to remove some casts.

> Also by randomly checking one of the affected non-static functions I
> found a bunch of calls like this:
>
> XLogRegisterData((char *) msgs, ...)
>
> ... where the first argument is going to become (const char *). It
> looks like the compilers are OK with implicitly casting (char*) to a
> more restrictive (const char*) though.

Yes, that's ok.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2024-09-03 06:21:59 Re: v17 vs v16 performance comparison
Previous Message shveta malik 2024-09-03 06:12:32 Re: DOCS - pg_replication_slot . Fix the 'inactive_since' description