public inbox for [email protected]  
help / color / mirror / Atom feed
From: legrand legrand <[email protected]>
To: [email protected] <[email protected]>
Subject: does multi host connection string supports login event trigger exception
Date: Thu, 19 Jun 2025 19:31:51 +0000
Message-ID: <AS8PR08MB6632193E0D8A5ED714026F84907DA@AS8PR08MB6632.eurprd08.prod.outlook.com> (raw)

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


reply

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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: does multi host connection string supports login event trigger exception
  In-Reply-To: <AS8PR08MB6632193E0D8A5ED714026F84907DA@AS8PR08MB6632.eurprd08.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox