Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wvV3n-001JtV-0r for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Aug 2026 07:13:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wvV3k-005fme-2u for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Aug 2026 07:13:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wvV3k-005fmW-1x for pgsql-hackers@lists.postgresql.org; Sun, 16 Aug 2026 07:13:33 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wvV3h-00000001178-0qce for pgsql-hackers@lists.postgresql.org; Sun, 16 Aug 2026 07:13:33 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id F1DEE7A00DB; Sun, 16 Aug 2026 03:13:26 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Sun, 16 Aug 2026 03:13:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1786864406; x=1786950806; bh=owCx8LKKyI 3N4kqqQ9axpZsBa8MyD5IJgLJnjaPi6mw=; b=S0BYTWg6Ocjur1SkWf9MXy0xuU mxbpUxDi/zKL12uBJ46jlA3InQhLPO96XZvcHtQx74LkrjHyC6TWNXtax3L9okwk yj1Dl09nBE5+KNu2hbhAgEx0A+MVq9mjyXvLCIKIF0U0iwtM0wqT2+8B2IdLPqXc 5TiEC6WEujnSn6xZtVT/yJVTLdnz72g0KMXldX9qkqRKh/BxnkpnUv/2xder5wEy +pnckWvhL73r/LZ8sYqqbzE3Ka9/LHuHSXrLdEl6RZA3wsPzEbZ8QJl9ggkMFoQ9 ua6b5gwvXp6WnlGESOmyKYEoKkWJ4mYjDfsltosYJVwWrX7p9hZKKwn9fhOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1786864406; x=1786950806; bh=owCx8LKKyI3N4kqqQ9axpZsBa8MyD5IJgLJ njaPi6mw=; b=U8jxP+FbX/xGIszT69SlfeD1rLlEIG+7TI9gusuFPJUmc676hIh jN42C1/GFDPlrO1NOWGZRR7B99mhsUj3QMJuy2BpZE2SMLXu63k+Kfdhcn4f67gm WEgvDJDGI6vC2IyqPmvL+XXz3PObyN5VGOqnQvmosjUpOwJo16Bey20PLUodolkU GVch7EnJXFasMFj4AZEHdzfwIjYllROnw7WMapuCPJEwNWLdwNzT9vkyz9FhJC6d QjamDedHZvlcbin0ve1RD/a0hf66QOhddH7D1SY1TmpEOHPgEKw4+Do5aqd/Hhxc u37DH4Wmt0gl8IOW8QeY9V/UT8HaXbbzRGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEIbMHyqPY86nu/XpwlKNsNShfYu/6ToxLnjfTLNW4+bsqhGJGmqblU3AYcQyQTng T2/VHxlZRmJwU9xIbF8iM3AjPh7LTJlMcpzo3Ge2tLebkfwCK17kfrxt46mdWXp+plZ8nv ht9hS89W8czGgxD93+EBrkt9MNeJRpGQ7hQGwOFYgwkA5nguNuSuF9HVtVLonqwqPlEqjg 0kmAFYJfSSY08etIuPggcaOawjsl25uiemhn7ts2/h3KS8def9m98hLgWvtXXNZLcYzo6T BmeeOFnl7wh0Yu2hy/c6QdIWLha5J1o6Q0CJd4y+GsRTWNF8nhBmYpv216VvJ0sErH1Hao TS/IRphVXXW0K1+aHwroXsiQKuH1nnFQeuanulHDdogjcMq0AwJxH4GYrZkxPgnMIeIcfR 22AErUaO6AgeoOQNxfH1do1sQCyKLvWhX7V948d2zXvBy5CqvucrVNiDiJARk/OgSxPXkl 0n/D71gVrBBveO7J1GhHkK/xI2pkEKERelPrCOKkcfY53gPQ3pVeK63ltztAglh6sFHDth vvhBt1CEndw6fst9K0X2q8u+SpdOQZ8vVMHqs5IVGhzauw6McCLwWbW+F6nUbgylTm5Rf3 Qqdf87+maAwouO3D3VO64HxMBSjrqevCr9RKgYwm+zC6vk7VXpOFf0YRQCMw X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 16 Aug 2026 03:13:24 -0400 (EDT) Date: Sun, 16 Aug 2026 16:13:20 +0900 From: Michael Paquier To: Matthias van de Meent Cc: PostgreSQL Hackers , Heikki Linnakangas Subject: Re: Thread-safe stringToNode() / pg_strtok() Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="0bdgnBykCGKwjZq6" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0bdgnBykCGKwjZq6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --0bdgnBykCGKwjZq6 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmqBYxAACgkQnvQgOdby QH1BJA/+Ps+bxu+ARt1R9AhiPvRa+JPKQA6NnTjmjO3LkOKf3ifzv948lvqtTLic BDXf9ohh3jRuYKf7Fi+g7ek/xsxAG2PzCQ22EyVdnXkXsX/dOu8ZDxHaAghN4Jh9 OEW1BVGe7CsUcF5qvBh2xhe0MfSHhV5ZyGpdJ1RlTRlOD98tgdGzA5cVOCfPkO/H zi2GE3TxelUyaPQzUljLheXcep+8J6IY/MfLRYiJ5JKzciDaumBbeZA0j+Z8tLXF dufQSkJkXd/clPOe7IjmG+OIqim3YWiJ1/Hjgb4qvF/lXkzBqGY0FaIhoPWzARwr FVQxOcgHR6lt809D8Z5mJCOwKgyLvf5Ic5crO3WwszCGBcRycvsVyEixEnkx0DQs DxVLaGj3rL9HIRe8wcbxa8iidfVmyMITOJ3ZTjkP93qra752Ic5zgMbGh7rwEKUS ALqtTiWGYi8nL8WqfEx6qMViMAmuWjpvbF0avNR7I9/vuIiYM1rWSoLxybcH8Xsc mfKCrGJVMg/9+l6YicTr18lafWFhAGzARriyu4yaoh1RTK38xs8+0SvikPXZJ14e TQmS59/yoch1PYgi+unLqcqQJezJtV9JZJ8PpHWFE/IH9vS8U3aVES407EmX9cs6 i5IF0Wxt75zgg9C3RzoIoQa42L/v3V+2H/slx7Xfy1p597HjpWQ= =37sd -----END PGP SIGNATURE----- --0bdgnBykCGKwjZq6--