Constraint's NO INHERIT option is ignored in CREATE TABLE LIKE statement - Mailing list pgsql-hackers

From Ildar Musin
Subject Constraint's NO INHERIT option is ignored in CREATE TABLE LIKE statement
Date
Msg-id CAONYFtMC6C+3AWCVp7Yd8H87Zn0GxG1_iQG6_bQKbaqYZY0=-g@mail.gmail.com
Whole thread Raw
Responses Re: Constraint's NO INHERIT option is ignored in CREATE TABLE LIKE statement
List pgsql-hackers
Hi hackers,

My colleague Chris Travers discovered something that looks like a bug.
Let's say we have a table with a constraint that is declared as NO INHERIT.

CREATE TABLE test (
    x INT CHECK (x > 0) NO INHERIT
);
\d test
                Table "public.test"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 x      | integer |           |          |
Check constraints:
    "test_x_check1" CHECK (x > 0) NO INHERIT

Now when we want to make a copy of the table structure into a new table
the `NO INHERIT` option is ignored.

CREATE TABLE test2 (LIKE test INCLUDING CONSTRAINTS);
\d test2
               Table "public.test2"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 x      | integer |           |          |
Check constraints:
    "test_x_check1" CHECK (x > 0)

Is this a bug or expected behaviour? Just in case I've attached a patch
that fixes this.

Regards,
Ildar
Attachment

pgsql-hackers by date:

Previous
From: ahsan hadi
Date:
Subject: Re: DROP OWNED CASCADE vs Temp tables
Next
From: Hamid Akhtar
Date:
Subject: Re: Do we need to handle orphaned prepared transactions in the server?