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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
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-16 07:13:20
Message-ID: aoFjAh0H7VBmhsZX@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

> There are other things we could do to improve this code (e.g.
> de/serializaing based on node descriptors instead of generated
> functions), but I consider such improvements to be out of scope for
> this patch; the attached is just a simple move from global variables
> to a context struct passed down the call stack.

That sounds fair.

Any thoughts or comments from others?
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-08-16 08:17:19 Re: A new C function `get_partition_root`.
Previous Message Michael Paquier 2026-08-16 06:57:25 Re: psql \d+ shows "Replica Identity: ???" for REPLICA IDENTITY NOTHING