Re: BUG #3973: pg_dump using inherited tables do not always restore

From: "Alex Hunsaker" <badalex(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: BUG #3973: pg_dump using inherited tables do not always restore
Date: 2008-03-03 19:07:46
Message-ID: 34d269d40803031107t4b353603h34ed6226659f218@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

On Wed, Feb 20, 2008 at 3:55 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Alex Hunsaker" <badalex(at)gmail(dot)com> writes:
> > create table junk (val integer not null, val2 integer);
> > create table junk_child () inherits (junk_1);
> > alter table junk_child alter column val drop not null;
> > insert into junk_child (val2) values (1);
>
> > pg_dump -t junk -t junk_child
>
> > pg_restore/psql will fail because junk_child.val now has a not null
> > constraint
>
> Actually the bug is that ALTER TABLE allows you to do that. It should
> not be possible to drop an inherited constraint, but right now there's
> not enough information in the system catalogs to detect the situation.
> Fixing this has been on the TODO list for awhile:
>
> o %Prevent child tables from altering or dropping constraints
> like CHECK that were inherited from the parent table
>
> regards, tom lane
>

Hrm how about something like the attached patch?

It only handles set not null/drop not null. And I thought about
making it so set default behaved the same way, but i can see how that
can be useful in the real world. Thoughts?

Arguably pg_dump should just do something similar to what it does for
set default (because that dumps correctly)... I only say that because
there specific regressions test for the behavior I outlined above.
Which is now "broken" with my patch.

Be gentle... its my first dive into postgresql guts...

Attachment Content-Type Size
inhertied_null.patch application/octet-stream 7.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Schweikert 2008-03-03 19:09:37 Re: BUG #4006: pg_ctl assumes that all config files lie in data_directory
Previous Message Bruce Momjian 2008-03-03 18:09:10 Re: [BUGS] BUG #4007: chr(0) doesn't work anymore

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2008-03-03 19:17:46 Re: [HACKERS] new warning message
Previous Message Bruce Momjian 2008-03-03 18:49:39 Re: Logging conflicted queries on deadlocks