From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Virendra Kumar <viru_7683@yahoo.com>
Cc: Pgsql-general General <pgsql-general@postgresql.org>
Subject: Re: Different Lock Behavior With Create and Drop Foreign Key
Date: Fri, 10 Apr 2020 12:13:59 -0400
Message-ID: <4147.1586535239@sss.pgh.pa.us> (raw)
In-Reply-To: <3a4e7019df93301b82a98ddbfa73d31170d03a45.camel@cybertec.at>
References: <834603375.3470346.1586482852542.ref@mail.yahoo.com>
<834603375.3470346.1586482852542@mail.yahoo.com>
<3a4e7019df93301b82a98ddbfa73d31170d03a45.camel@cybertec.at>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, viru_7683@yahoo.com
Subject: Re: Different Lock Behavior With Create and Drop Foreign Key
In-Reply-To: <4147.1586535239@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox