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

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, 邱宇航 <iamqyh(at)gmail(dot)com>
Subject: Re: Thread-safe stringToNode() / pg_strtok()
Date: 2026-08-19 13:13:42
Message-ID: CAEze2WheHx03p1Cqxua-3OmqeDKBey=T7vZGfNZ2Cug7vEMR+A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 19 Aug 2026 at 10:46, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> On 17.08.26 13:36, Matthias van de Meent wrote:
> > 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.

Thanks for noticing. An (unposted) earlier version stored a
StringInfoData, using its cursor field for decoding in pg_strtok(),
instead of changing the base string pointer.
The comment references the unconstify() needed to populate this
StringInfoData's non-const char* field.

Attached is patch v3, with new changes:
- Further simplified stringToNodeInternal;
- Another round of comments cleanup, including the one Peter pointed out;
- Added a small comment describing the ReadNodeContext struct;
- Fixed _readExtensibleNode()/ExtensibleNodeMethods->nodeRead(), per
Yuhang Qiu's review.

Kind regards,

Matthias van de Meent

Attachment Content-Type Size
v3-0001-Make-stringToNode-infrastructure-thread-safe.patch application/octet-stream 25.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2026-08-19 13:15:35 Re: Race conditions in logical decoding
Previous Message Amit Langote 2026-08-19 13:12:43 Re: PG19 FK fast path: OOB write and missed FK checks during batched