Thread: Bug in 8.2 (&8.1) dump & restore

Bug in 8.2 (&8.1) dump & restore

From
Scott Ribe
Date:
create database test;
\c test
create table base (foo int not null);
create table derived () inherits (base);
alter table derived alter foo drop not null;
insert into derived values(null);

Dump it, and the dump will not include any command to drop the not null
constraint on derived.foo, so restore will fail.

--
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice



Re: Bug in 8.2 (&8.1) dump & restore

From
Tom Lane
Date:
Scott Ribe <scott_ribe@killerbytes.com> writes:
> create database test;
> \c test
> create table base (foo int not null);
> create table derived () inherits (base);
> alter table derived alter foo drop not null;
> insert into derived values(null);

> Dump it, and the dump will not include any command to drop the not null
> constraint on derived.foo, so restore will fail.

Actually, the bug there is that ALTER TABLE lets you set up a
self-inconsistent inheritance hierarchy.  The above should be illegal
because it would mean that "select foo from base" could return nulls,
contradicting the clear definition of the table.

We've been talking about fixing that, but it'll probably take catalog
changes (to be able to track which constraints were inherited from a
parent table) so this isn't ever going to be enforced by any existing
release.

            regards, tom lane