Re: not null constraints, again - Mailing list pgsql-hackers

From jian he
Subject Re: not null constraints, again
Date
Msg-id CACJufxGeq2xVq_FN21=iLK5uKnbnH4o_B3FEofP1H_xuzkAtMQ@mail.gmail.com
Whole thread Raw
In response to Re: not null constraints, again  (jian he <jian.universality@gmail.com>)
Responses Re: not null constraints, again
List pgsql-hackers
sql-altertable.html

   <varlistentry id="sql-altertable-desc-set-drop-not-null">
    <term><literal>SET</literal>/<literal>DROP NOT NULL</literal></term>
    <listitem>
     <para>
      These forms change whether a column is marked to allow null
      values or to reject null values.
     </para>
     <para>
      If this table is a partition, one cannot perform <literal>DROP
NOT NULL</literal>
      on a column if it is marked <literal>NOT NULL</literal> in the parent
      table.  To drop the <literal>NOT NULL</literal> constraint from all the
      partitions, perform <literal>DROP NOT NULL</literal> on the parent
      table.
     </para>
Now this will be slightly inaccurate.

drop table if exists part, part0 cascade;
create table part (a int not null) partition by range (a);
create table part0 (a int not null);
alter table part attach partition part0 for values from (0) to (1000);
alter table ONLY part0 add primary key(a);
alter table part alter column a drop not null;

as the example shows that part0 not-null constraint is still there.
that means:

perform <literal>DROP NOT NULL</literal> on the parent table
will not drop the <literal>NOT NULL</literal> constraint from all partitions.

so we need rephrase the following sentence:

To drop the <literal>NOT NULL</literal> constraint from all the
      partitions, perform <literal>DROP NOT NULL</literal> on the parent
      table.

to address this kind of corner case?



pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Doc: typo in ddl.sgml
Next
From: Amit Kapila
Date:
Subject: Re: Disallow UPDATE/DELETE on table with unpublished generated column as REPLICA IDENTITY