From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aaron Sipser <ajsipser@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Locks on FK Tables From Partitioning
Date: Tue, 08 Feb 2022 18:13:49 -0500
Message-ID: <1298506.1644362029@sss.pgh.pa.us> (raw)
In-Reply-To: <CACjAnu3oeETOhD0tDLJoJmS7yJZBWEij3qKhxafdXKOuCYzPSw@mail.gmail.com>
References: <CACjAnu3oeETOhD0tDLJoJmS7yJZBWEij3qKhxafdXKOuCYzPSw@mail.gmail.com>
Aaron Sipser <ajsipser@gmail.com> writes:
> I am fairly confused about the locks generated by some partitioning code I
> am using. The setup is that we have a partitioned table (call it P), and it
> has a foreign key constraint to another table F. I'm trying to figure out
> why when I add partitions to P, it seems that a lock is also taken on F.
Addition of a foreign key constraint implies adding triggers to both sides
of the FK. Adding a new partition also adds a child foreign key
constraint, which I'm pretty sure requires its own trigger. So the F
table is going to need whatever lock strength is involved in CREATE
TRIGGER. I don't recall offhand what we use, but it would at least need
to block operations that might fire such a trigger.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, ajsipser@gmail.com
Subject: Re: Locks on FK Tables From Partitioning
In-Reply-To: <1298506.1644362029@sss.pgh.pa.us>
References: <CACjAnu3oeETOhD0tDLJoJmS7yJZBWEij3qKhxafdXKOuCYzPSw@mail.gmail.com> <1298506.1644362029@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