[oauth] Per connection auth hooks in libpq - Mailing list pgsql-hackers

From Andreas Karlsson
Subject [oauth] Per connection auth hooks in libpq
Date
Msg-id 19f9da27-295d-4194-b38c-8e5142dfae4b@proxel.se
Whole thread Raw
Responses Re: [oauth] Per connection auth hooks in libpq
Re: [oauth] Per connection auth hooks in libpq
List pgsql-hackers
Hi,

When implementing OAuth support in the PostgreSQL driver for Ruby[1] the 
main pain point I ran into was that the PQauthDataHook is global which 
does not work well at all given how Ruby supports multiple sub-instances 
of the Ruby runtime (so called Ractors) plus that if you would load e.g. 
Python and Ruby into the same process and both would use libpq they 
would have to fight over the global hook.

So attached is a proof of concept patch which implements a 
per-connection hook. It is just a rough patch to start a discussion. If 
people like it I can clean it up and add tests and documentation.

Notes

1. See these two PRs: one which uses a per-runtime map and one which 
uses a per-PGConn hash map. I am not a fan of either.

- https://github.com/ged/ruby-pg/pull/693
- https://github.com/ged/ruby-pg/pull/700

-- 
Andreas Karlsson
Percona

Attachment

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: typo in alter_table.sgml (was: Re: pgsql: Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK)
Next
From: Jacob Champion
Date:
Subject: Re: [oauth] Per connection auth hooks in libpq