Re: On login trigger: take three

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Ivan Panchenko <wao(at)mail(dot)ru>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Nancarrow <gregn4422(at)gmail(dot)com>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, a(dot)sokolov(at)postgrespro(dot)ru
Subject: Re: On login trigger: take three
Date: 2022-09-02 16:13:39
Message-ID: CALNJ-vTEH3tbfysyijg8M0m29T5g2u14TUAdvZwOzpLgO+bweQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 2, 2022 at 8:37 AM Daniel Gustafsson <daniel(at)yesql(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-09-02 16:35:15 Re: [RFC] building postgres with meson - v12
Previous Message Robert Haas 2022-09-02 15:55:51 Re: Remove dead code from sepgsql