Re: CREATE TABLE NOT VALID for check and foreign key

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE TABLE NOT VALID for check and foreign key
Date: 2025-01-15 10:46:34
Message-ID: 202501151046.jhmyohktujmm@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-Jan-15, Amul Sul wrote:

> I might be mistaken, but I believe this behavior is reasonable since
> we're creating a new table with no data initially. Future inserts will
> be validated against the constraint, ensuring all data added complies
> with it. Given that any data in the table at any time will be valid
> according to the constraint, marking it as "VALID" seems like the
> correct approach, IMO.

Yes to all of the above. But the complaint is not that the behavior is
incorrect. The complaint is that users add NOT VALID and the code
silently behaves as if the parameter was not given, which surprises them
unpleasantly. The WARNING message is there to tell them "look, I
realize you wanted to do this, but I know better, so I decided to ignore
you." That's all.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Use it up, wear it out, make it do, or do without"

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-01-15 10:55:44 Re: per backend I/O statistics
Previous Message Ajin Cherian 2025-01-15 10:24:38 Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.