Re: Different Lock Behavior With Create and Drop Foreign Key

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Different Lock Behavior With Create and Drop Foreign Key
Дата
Msg-id 4147.1586535239@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Different Lock Behavior With Create and Drop Foreign Key  (Laurenz Albe <laurenz.albe@cybertec.at>)
Список pgsql-general
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Fri, 2020-04-10 at 01:40 +0000, Virendra Kumar wrote:
>> [ $subject ]

> That is because foreign keys are implemented with system triggers, some of which
> are defined on the target table.
> Now CREATE TRIGGER does not require an ACCESS EXCLUSIVE lock, but DROP TRIGGER does.

Yeah.  The documentation could be clearer about this though.  The relevant
bit on the ALTER TABLE page is

    Addition of a foreign key constraint requires a SHARE ROW EXCLUSIVE
    lock on the referenced table, in addition to the lock on the table
    receiving the constraint.

which, at least to my eyes, isn't very clear that SHARE ROW EXCLUSIVE
is the lock level used for *both* tables.

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: Different Lock Behavior With Create and Drop Foreign Key
Следующее
От: "Andrus"
Дата:
Сообщение: Huge number of pg_temp and pg_toast_temp schemas