Re: pg_dump problem with dropped NOT NULL on child table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump problem with dropped NOT NULL on child table
Date: 2016-01-13 20:32:12
Message-ID: 25783.1452717132@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2016-01-13 20:34:30 Re: Synchronous replication
Previous Message drum.lucas@gmail.com 2016-01-13 20:31:57 Re: New Slave - timeline ERROR