Re: CREATE TABLE NOT VALID for check and foreign key

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE TABLE NOT VALID for check and foreign key
Date: 2024-12-05 12:30:13
Message-ID: CACJufxGj3VW0LktZLGjB1H-poELzYzuqfkVB3c9cAp4jzkxc7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

turns out this has already been discussed at [1]
NOT VALID only applies to table_constraint.
Amit Langote actually wrote the doc at[1], so I copied some text from there.

in create_table.sgml, i placed right below
<term><literal>INITIALLY IMMEDIATE</literal></term>
<term><literal>INITIALLY DEFERRED</literal></term>
so it looks like this:

<varlistentry id="sql-createtable-parms-notvalid">
<term><literal>NOT VALID</literal></term>
<listitem>
<para>
This applies only to <literal>CHECK</literal> and foreign key constraints.
Note even if the constraint is marked as <literal>NOT VALID</literal>,
it is considered as validated since the newly created table will not
contain any data. In other words, specifying <literal>NOT
VALID</literal> has no effect.
</para>
</listitem>
</varlistentry>

[1] https://www.postgresql.org/message-id/flat/d2b7419f-4a71-cf86-cc99-bfd0f359a1ea%40lab.ntt.co.jp

Attachment Content-Type Size
not_valid_create_table.diff text/x-patch 1.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2024-12-05 12:46:48 Re: code contributions for 2024, WIP version
Previous Message Kirill Reshke 2024-12-05 12:22:34 Re: Pass ParseState as down to utility functions.