From b5cef56f15aec91ead15f8f67dc639cdaf49908e Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Mon, 14 Mar 2022 14:40:04 +0100 Subject: [PATCH v26 3/3] Add IGNORE_EVENT_TRIGGER_LOGIN --- doc/src/sgml/event-trigger.sgml | 6 ++++-- src/backend/commands/event_trigger.c | 10 +++++++--- src/backend/utils/misc/guc.c | 1 + src/include/commands/event_trigger.h | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/event-trigger.sgml b/doc/src/sgml/event-trigger.sgml index 1d10b98b76..1577426dc3 100644 --- a/doc/src/sgml/event-trigger.sgml +++ b/doc/src/sgml/event-trigger.sgml @@ -40,8 +40,10 @@ The login event occurs when a user logs in to the system. Any bugs in a trigger procedure for this event may prevent successful - login to the system. Such bugs may be fixed after first restarting the - system in single-user mode (as event triggers are disabled in this mode). + login to the system. Such bugs may be fixed after first reconnecting to + the system with event triggers disabled (see ) + or using restarting the system in single-user mode (as event triggers are + disabled in this mode). See the reference page for details about using single-user mode. diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index ef09080a74..ca9b7c2efd 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -858,7 +858,8 @@ EventTriggerOnLogin(void) * See EventTriggerDDLCommandStart for a discussion about why event * triggers are disabled in single user mode. */ - if (!IsUnderPostmaster || !OidIsValid(MyDatabaseId)) + if (!IsUnderPostmaster || !OidIsValid(MyDatabaseId) + || ignore_event_trigger_check(EVT_Login)) return; StartTransactionCommand(); @@ -2312,8 +2313,7 @@ stringify_adefprivs_objtype(ObjectType objtype) /* * Checks whether the specified event is ignored by the ignore_event_trigger - * GUC or not. Currently, the GUC only supports ignoreing all or nothing but - * that will most likely change so the function takes an event to aid that. + * GUC or not. */ static bool ignore_event_trigger_check(EventTriggerEvent event) @@ -2323,6 +2323,10 @@ ignore_event_trigger_check(EventTriggerEvent event) if (ignore_event_trigger == IGNORE_EVENT_TRIGGER_ALL) return true; + if (ignore_event_trigger == IGNORE_EVENT_TRIGGER_LOGIN + && event == EVT_Login) + return true; + /* IGNORE_EVENT_TRIGGER_NONE */ return false; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 088c4690d9..c5d53386e7 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -569,6 +569,7 @@ static const struct config_enum_entry wal_compression_options[] = { static const struct config_enum_entry ignore_event_trigger_options[] = { {"none", IGNORE_EVENT_TRIGGER_NONE, false}, {"all", IGNORE_EVENT_TRIGGER_ALL, false}, + {"login", IGNORE_EVENT_TRIGGER_LOGIN, false}, {NULL, 0, false} }; diff --git a/src/include/commands/event_trigger.h b/src/include/commands/event_trigger.h index 4d9e7dba94..2400cc7d7a 100644 --- a/src/include/commands/event_trigger.h +++ b/src/include/commands/event_trigger.h @@ -32,7 +32,8 @@ typedef struct EventTriggerData typedef enum ignore_event_trigger_events { IGNORE_EVENT_TRIGGER_NONE, - IGNORE_EVENT_TRIGGER_ALL + IGNORE_EVENT_TRIGGER_ALL, + IGNORE_EVENT_TRIGGER_LOGIN } IgnoreEventTriggersEvents; extern int ignore_event_trigger; -- 2.24.3 (Apple Git-128)