From: Jacob Champion <jchampion@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock()
Date: Thu, 05 Mar 2026 18:12:03 +0000
Message-ID: <E1vyDB5-002YEh-0J@gemulon.postgresql.org> (raw)
libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock()
Allow libpq clients to retrieve the current pg_g_threadlock pointer with
PQgetThreadLock(). Single-threaded applications could already do this in
a convoluted way:
pgthreadlock_t tlock;
tlock = PQregisterThreadLock(NULL);
PQregisterThreadLock(tlock); /* re-register the callback */
/* use tlock */
But a generic library can't do that without potentially breaking
concurrent libpq connections.
The motivation for doing this now is the libpq-oauth plugin, which
currently relies on direct injection of pg_g_threadlock, and should
ideally not.
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://postgr.es/m/CAOYmi%2BmEU_q9sr1PMmE-4rLwFN%3DOjyndDwFZvpsMU3RNJLrM9g%40mail.gmail.com
Discussion: https://postgr.es/m/CAOYmi%2B%3DMHD%2BWKD4rsTn0v8220mYfyLGhEc5EfhmtqrAb7SmC5g%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/b8d76858353e40f888c809eb14a974cf13bf23ab
Modified Files
--------------
doc/src/sgml/libpq.sgml | 6 +++++-
src/interfaces/libpq/exports.txt | 1 +
src/interfaces/libpq/fe-connect.c | 7 +++++++
src/interfaces/libpq/libpq-fe.h | 10 ++++++++--
4 files changed, 21 insertions(+), 3 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: jchampion@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock()
In-Reply-To: <E1vyDB5-002YEh-0J@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox