Event trigger and CREATE/ALTER ROLE/USER

Started by Tatsuo Ishiiover 9 years ago9 messages
#1Tatsuo Ishii
ishii@sraoss.co.jp

Simple question: Is there any reason for event trigger to not support
CREATE/ALTER ROLE/USER?

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Michael Paquier
michael.paquier@gmail.com
In reply to: Tatsuo Ishii (#1)
Re: Event trigger and CREATE/ALTER ROLE/USER

On Wed, Sep 14, 2016 at 9:26 AM, Tatsuo Ishii <ishii@sraoss.co.jp> wrote:

Simple question: Is there any reason for event trigger to not support
CREATE/ALTER ROLE/USER?

Because it performs a global administrative task, no?
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Tatsuo Ishii
ishii@sraoss.co.jp
In reply to: Michael Paquier (#2)
Re: Event trigger and CREATE/ALTER ROLE/USER

Simple question: Is there any reason for event trigger to not support
CREATE/ALTER ROLE/USER?

Because it performs a global administrative task, no?

So is there any technical difficulty? Can you please elaborate?

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Michael Paquier
michael.paquier@gmail.com
In reply to: Tatsuo Ishii (#3)
Re: Event trigger and CREATE/ALTER ROLE/USER

On Wed, Sep 14, 2016 at 9:34 AM, Tatsuo Ishii <ishii@sraoss.co.jp> wrote:

Simple question: Is there any reason for event trigger to not support
CREATE/ALTER ROLE/USER?

Because it performs a global administrative task, no?

So is there any technical difficulty?

I don't recall the exact details but...

Can you please elaborate?

Roles are global objects, and event triggers cannot operate on such
ones. See for example 296f3a60 mentioning for example why REVOKE/GRANT
can only operate on local objects.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Tatsuo Ishii
ishii@sraoss.co.jp
In reply to: Michael Paquier (#4)
Re: Event trigger and CREATE/ALTER ROLE/USER

Simple question: Is there any reason for event trigger to not support
CREATE/ALTER ROLE/USER?

Because it performs a global administrative task, no?

So is there any technical difficulty?

I don't recall the exact details but...

Can you please elaborate?

Roles are global objects, and event triggers cannot operate on such
ones. See for example 296f3a60 mentioning for example why REVOKE/GRANT
can only operate on local objects.

Thanks. I will look into it.

Pgpool-II has its own password file which needs to be sync with the
md5 hashed password of PostgreSQL. So I thought it would be nice if
the event trigger could be used for the purpose.

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tatsuo Ishii (#1)
Re: Event trigger and CREATE/ALTER ROLE/USER

Tatsuo Ishii wrote:

Simple question: Is there any reason for event trigger to not support
CREATE/ALTER ROLE/USER?

As I understand the issue, the main reason is that event triggers
execute procedures, and those exist in a single database only. If you
were to create an event trigger in database A, then a user gets created
in database B, your function would not be invoked, which becomes a
problem.

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7Craig Ringer
craig.ringer@2ndquadrant.com
In reply to: Alvaro Herrera (#6)
Re: Event trigger and CREATE/ALTER ROLE/USER

On 14 Sep. 2016 9:44 am, "Alvaro Herrera" <alvherre@2ndquadrant.com> wrote:

Tatsuo Ishii wrote:

Simple question: Is there any reason for event trigger to not support
CREATE/ALTER ROLE/USER?

As I understand the issue, the main reason is that event triggers
execute procedures, and those exist in a single database only. If you
were to create an event trigger in database A, then a user gets created
in database B, your function would not be invoked, which becomes a
problem.

Yeah... You'd need something at the C level as a hook because you can't
rely on pg_proc etc.

For BDR I've been thinking of optionally replicating such actions using a
ProcessUtility_hook and deparse or simply verbatim sql capture. Then
replicating via generic logical wal messages.

#8Tatsuo Ishii
ishii@sraoss.co.jp
In reply to: Alvaro Herrera (#6)
Re: Event trigger and CREATE/ALTER ROLE/USER

As I understand the issue, the main reason is that event triggers
execute procedures, and those exist in a single database only. If you
were to create an event trigger in database A, then a user gets created
in database B, your function would not be invoked, which becomes a
problem.

Can't we just create the event trigger in database B as well? We have
been living with similar situation, for example, functions for years.
(a work around would be creating functions in template1. This only
works for freshly created database though).
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#9Michael Paquier
michael.paquier@gmail.com
In reply to: Tatsuo Ishii (#8)
Re: Event trigger and CREATE/ALTER ROLE/USER

On Wed, Sep 14, 2016 at 11:09 AM, Tatsuo Ishii <ishii@sraoss.co.jp> wrote:

As I understand the issue, the main reason is that event triggers
execute procedures, and those exist in a single database only. If you
were to create an event trigger in database A, then a user gets created
in database B, your function would not be invoked, which becomes a
problem.

Can't we just create the event trigger in database B as well? We have
been living with similar situation, for example, functions for years.
(a work around would be creating functions in template1. This only
works for freshly created database though).

Just a random thought: wouldn't what you are looking for be more
reliable if you use the utility hook and have it loaded via
preload_shared_libraries?
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers