| From: | Jacob Champion <jchampion(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: libpq: Add PQgetThreadLock() to mirror PQregisterThreadLock() |
| Date: | 2026-03-05 18:12:03 |
| Message-ID: | E1vyDB5-002YEh-0J@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(dot)parragi(at)percona(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-03-05 19:43:39 | pgsql: Exit after fatal errors in client-side compression code. |
| Previous Message | Alexander Korotkov | 2026-03-05 18:08:13 | pgsql: Fix handling of updated tuples in the MERGE statement |