From: | Ildar Musin <ildar(at)adjust(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Constraint's NO INHERIT option is ignored in CREATE TABLE LIKE statement |
Date: | 2020-02-19 13:59:40 |
Message-ID: | CAONYFtMC6C+3AWCVp7Yd8H87Zn0GxG1_iQG6_bQKbaqYZY0=-g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg범퍼카 토토SQL |
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 | Content-Type | Size |
---|---|---|
copy_constr_noinherit.patch | text/x-patch | 589 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Hamid Akhtar | 2020-02-19 15:04:50 | Re: Do we need to handle orphaned prepared transactions in the server? |
Previous Message | ahsan hadi | 2020-02-19 13:59:21 | Re: DROP OWNED CASCADE vs Temp tables |