Re: On login trigger: take three - Mailing list pgsql-hackers

From Zhihong Yu
Subject Re: On login trigger: take three
Date
Msg-id CALNJ-vTEH3tbfysyijg8M0m29T5g2u14TUAdvZwOzpLgO+bweQ@mail.gmail.com
Whole thread Raw
In response to Re: On login trigger: take three  (Daniel Gustafsson <daniel@yesql.se>)
List pgsql-hackers


On Fri, Sep 2, 2022 at 8:37 AM Daniel Gustafsson <daniel@yesql.se> wrote:
This had bitrotted a fair bit, attached is a rebase along with (mostly)
documentation fixes.  0001 adds a generic GUC for ignoring event triggers and
0002 adds the login event with event trigger support, and hooks it up to the
GUC such that broken triggers wont require single-user mode.  Moving the CF
entry back to Needs Review.

--
Daniel Gustafsson               https://vmware.com/

Hi,
For EventTriggerOnLogin():

+           LockSharedObject(DatabaseRelationId, MyDatabaseId, 0, AccessExclusiveLock);
+
+           tuple = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
+
+           if (!HeapTupleIsValid(tuple))
+               elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);

Should the lock be taken after the check (HeapTupleIsValid) is done ?

Cheers

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Remove dead code from sepgsql
Next
From: Andres Freund
Date:
Subject: Re: [RFC] building postgres with meson - v12