From: | legrand legrand <legrand_legrand(at)hotmail(dot)com> |
---|---|
To: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | does multi host connection string supports login event trigger exception |
Date: | 2025-06-19 19:31:51 |
Message-ID: | AS8PR08MB6632193E0D8A5ED714026F84907DA@AS8PR08MB6632.eurprd08.prod.outlook.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello to all the readers,
I'm trying to build a login event trigger in conjonction with a multi host connectio string
to manager instances roles in a logical replication cluster.
I'm surprised by the result found with (pg client 16+ on windows and linux),
here is my test case:
--on XX server
--create a LOGIN EVENT TRIGGER
--psql
CREATE OR REPLACE FUNCTION init_session()
RETURNS event_trigger SECURITY DEFINER
LANGUAGE plpgsql AS
$$
BEGIN
IF session_user = 'aaaaa' THEN
RAISE EXCEPTION 'Login forbidden';
END IF;
END;
$$;
-- trigger definition
CREATE EVENT TRIGGER init_session
ON login
EXECUTE FUNCTION init_session();
ALTER EVENT TRIGGER init_session ENABLE ALWAYS;
No trigger on YY server
--on ZZ server
set PGPASSWORD=pass
psql -d "host=XX,YY dbname=postgres port=5432 user=aaaaa"
psql: error: connection to server at "XX" (xx.xx.xx.xx), port 5432 failed: FATAL: Login forbidden
CONTEXT: PL/pgSQL function init_session() line 4 at RAISE
** It exits without trying connection on YY host !?**
Similar connection string on JDBC work as I wish:
*
try XX, with error
*
then try YY server and succeed.
Did I miss something ?
Regards
PAscal
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Luzanov | 2025-06-19 20:01:48 | Re: does multi host connection string supports login event trigger exception |
Previous Message | Laurenz Albe | 2025-06-19 16:35:55 | Re: Extension disappearing act |