Re: pg_dump problem with dropped NOT NULL on child table - Mailing list pgsql-general

From Tom Lane
Subject Re: pg_dump problem with dropped NOT NULL on child table
Date
Msg-id 25783.1452717132@sss.pgh.pa.us
Whole thread Raw
In response to pg_dump problem with dropped NOT NULL on child table  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Responses Re: pg_dump problem with dropped NOT NULL on child table
List pgsql-general
Karsten Hilbert <Karsten.Hilbert@gmx.net> writes:
> Please consider the following:

>     create table parent (
>         not_null_in_parent integer not null
>     );

>     create table child() inherits (parent);
>     alter table child
>         alter column not_null_in_parent
>             drop not null
>     ;

> Is this a bug or am I doing things I shouldn't hope work ?

You should not expect this to work; sooner or later we will make
the backend reject it.  See
http://www.postgresql.org/message-id/21633.1448383428@sss.pgh.pa.us

Alvaro or someone had a WIP patch to track NOT NULL constraints in
pg_constraint, which is the bookkeeping we'd need to deal with this
sort of thing properly.  I'm not sure what the status of it is.

In the meantime, you could get the effect you want if the parent
were marked with CHECK (not_null_in_parent IS NOT NULL) NO INHERIT.

            regards, tom lane


pgsql-general by date:

Previous
From: jwiencek3@comcast.net
Date:
Subject: Synchronous replication
Next
From: "drum.lucas@gmail.com"
Date:
Subject: Re: New Slave - timeline ERROR