does multi host connection string supports login event trigger exception - Mailing list pgsql-general

From legrand legrand
Subject does multi host connection string supports login event trigger exception
Date
Msg-id AS8PR08MB6632193E0D8A5ED714026F84907DA@AS8PR08MB6632.eurprd08.prod.outlook.com
Whole thread Raw
Responses Re: does multi host connection string supports login event trigger exception
List 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:

Did I miss something ?
Regards
PAscal

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Extension disappearing act
Next
From: Pavel Luzanov
Date:
Subject: Re: does multi host connection string supports login event trigger exception