Re: Thread-safe stringToNode() / pg_strtok()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: Thread-safe stringToNode() / pg_strtok()
Date: 2026-08-19 08:46:34
Message-ID: 67e173d6-8be7-4aea-9615-745acb4877da@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 17.08.26 13:36, Matthias van de Meent wrote:
> On Sun, 16 Aug 2026 at 09:13, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>>
>> On Fri, Aug 14, 2026 at 04:08:24PM +0200, Matthias van de Meent wrote:
>>> In line with various other efforts making things more re-entrant and
>>> thread-safe, here's a patch that makes stringToNode (and pg_strtok
>>> with it) thread safe.
>>
>> I have been reading the patch (not tested, just looking at the diffs),
>> and using a context as you are doing sounds like an acceptable thing
>> to do to remove the static pointer used by pg_strtok(). At least the
>> change makes sense here when taken in isolation.
>
> Thanks for looking!
>
>> Any thoughts or comments from others?
>
> One update for the patch. This fixes non-DEBUG_NODE_TESTS_ENABLED
> builds; I forgot to update the READ_LOCATION_FIELD definition in those
> non-debug builds, CI picked this up quite quickly but I didn't get to
> fixing it until today.

The patch contains a comment:

+ * We don't have a separate type for const StringInfos, unconstify +
+ * careful coding will have to suffice.

But the patch doesn't contain any unconstify() calls.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-08-19 08:51:07 Re: pg_control_checkpoint(): add "data_checksum_version" (Pg19)?
Previous Message Daniel Gustafsson 2026-08-19 08:38:39 Re: pg_control_checkpoint(): add "data_checksum_version" (Pg19)?