CREATE TABLE NOT VALID for check and foreign key - Mailing list pgsql-hackers

From jian he
Subject CREATE TABLE NOT VALID for check and foreign key
Date
Msg-id CACJufxEQcHNhN6M18JY1mQcgQq9Gn9ofMeop47SdFDE5B8wbug@mail.gmail.com
Whole thread Raw
Responses Re: CREATE TABLE NOT VALID for check and foreign key
List pgsql-hackers
hi.
I found for foreign keys, check constraints,
you specify it as NOT VALID, it will not be marked as NOT VALID in the
CREATE TABLE statement.

CREATE TABLE s6(id bigint , CONSTRAINT con1 check(id > 1) not valid);
src2=# \d s6
                Table "public.s6"
 Column |  Type  | Collation | Nullable | Default
--------+--------+-----------+----------+---------
 id     | bigint |           |          |
Check constraints:
    "con1" CHECK (id > 1)

create table pk (a int, primary key(a));
create table fk (a int, b int, foreign key(a) references pk( a) not valid);
                 Table "public.fk"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 a      | integer |           |          |
 b      | integer |           |          |
Foreign-key constraints:
    "fk_a_fkey" FOREIGN KEY (a) REFERENCES pk(a)

reading transformCheckConstraints, transformFKConstraints comments
appearingly this is intentional?

If so, do we need to document the keywords "NOT VALID"
in create_table.sgml synopsis section?



pgsql-hackers by date:

Previous
From: Masahiro Ikeda
Date:
Subject: Re: Track the amount of time waiting due to cost_delay
Next
From: Bertrand Drouvot
Date:
Subject: Re: Make pg_stat_io view count IOs as bytes instead of blocks