pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Álvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Allow NOT VALID foreign key constraints on partitioned tables
Date: Fri, 24 Jan 2025 15:48:54 +0900
Message-ID: <Z5M31tXuutq405K0@paquier.xyz> (raw)
In-Reply-To: <E1taygE-0036kE-Fh@gemulon.postgresql.org>
References: <E1taygE-0036kE-Fh@gemulon.postgresql.org>

Hi Alvaro.

On Thu, Jan 23, 2025 at 02:59:38PM +0000, Alvaro Herrera wrote:
> Allow NOT VALID foreign key constraints on partitioned tables
> 
> This feature was intentionally omitted when FKs were first implemented
> for partitioned tables, and had been requested a few times; the
> usefulness is clear.
> 
> Validation can happen for each partition individually, which is useful
> to contain the number of locks held and the duration; or it can be
> executed for the partitioning hierarchy as a single command, which
> validates all child constraints that haven't been validated already.
> 
> This is also useful to implement NOT ENFORCED constraints on top.

morepork at [1] is telling that these two queries are missing an ORDER
BY to ensure a proper ordering of the output generated:
+-- Constraint will be invalid.
+SELECT conname, convalidated FROM pg_constraint WHERE conrelid = 'fk_notpartitioned_fk'::regclass; 
[...]
+-- All constraints are now valid.
+SELECT conname, convalidated FROM pg_constraint WHERE conrelid = 'fk_notpartitioned_fk'::regclass; 

[1]: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=morepork&dt=2025-01-23%2023%3A35%3A57

Thanks,
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (3+ messages)  latest in thread

Message-ID: <Z5M31tXuutq405K0@paquier.xyz>
Permalink:  ../Z5M31tXuutq405K0@paquier.xyz/
Also on:    postgresql.org/message-id/Z5M31tXuutq405K0@paquier.xyz

 · 

reply

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-committers@postgresql.org
  Cc: michael@paquier.xyz, alvherre@alvh.no-ip.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow NOT VALID foreign key constraints on partitioned tables
  In-Reply-To: <Z5M31tXuutq405K0@paquier.xyz>

* 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