Re: CREATE TABLE LIKE INCLUDING TRIGGERS - Mailing list pgsql-hackers

From Zsolt Parragi
Subject Re: CREATE TABLE LIKE INCLUDING TRIGGERS
Date
Msg-id CAN4CZFNPE_UeTEy5TH9wwc6mBAtX7vnBhLSL47jRiHXA=6yXjQ@mail.gmail.com
Whole thread Raw
In response to Re: CREATE TABLE LIKE INCLUDING TRIGGERS  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
> > Shouldn't this preserve the enabled state of the triggers, or if it
> > doesn't, should the documentation include this limitations?
> >
>
> I intended to document it as ...


After looking into this a bit more, I am more on the side of copying
this setting properly.

The already existing INCLUDING CONSTRAINTS copies the constraints,
including their enabled/disabled status, correctly marking them
disabled if a CHECK constraint is defined but not enforced. Wouldn't
it be strange for INCLUDING TRIGGERS to work differently?

From the test suite:

CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING
COMMENTS) INHERITS (ctlt1);
\d+ ctlt1_inh
                                Table "public.ctlt1_inh"
 Column | Type | Collation | Nullable | Default | Storage  | Stats
target | Description
--------+------+-----------+----------+---------+----------+--------------+-------------
 a      | text |           | not null |         | main     |              | A
 b      | text |           |          |         | extended |              | B
Check constraints:
    "cc" CHECK (length(b) > 100)
    "ctlt1_a_check" CHECK (length(a) > 2)
    "ctlt1_b_check" CHECK (length(b) > 100) NOT ENFORCED
Not-null constraints:
    "ctlt1_a_not_null" NOT NULL "a" (local, inherited)
Inherits: ctlt1



pgsql-hackers by date:

Previous
From: Konstantin Knizhnik
Date:
Subject: Re: Mystery with REVOKE PRIVILEGE
Next
From: jian he
Date:
Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row