Allow child table to be missing nullable column from parent. - Mailing list pgsql-hackers

From Jeff Janes
Subject Allow child table to be missing nullable column from parent.
Date
Msg-id CAMkU=1wJGUnaaksTn7t3cekArVv4LkCfL4RaVkhJbiMb-dTHzQ@mail.gmail.com
Whole thread Raw
Responses Re: Allow child table to be missing nullable column from parent.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Currently a child table has to have all the columns the parent table has:

create table foo1 (x integer, y text, z bool);
create table foo2 (x integer, y text, q text);
alter table foo2 inherit foo1 ;
ERROR:  child table is missing column "z"

In theory it seems like this could be allowed as long as the parent
column is nullable, then the column is just deemed to be all null in
the child.  You can emulate such a situation using views rather than
inheritance:

create view foo4 as (select * from foo1 union all select x,y,
NULL::bool as z from foo2);

I would have found the ability to do this via inheritance to be
convenient a couple times, as a temporary measure while doing some
refactoring.   Or at least I think I would found it convenient,
perhaps I would have actually just shot myself in the foot with it for
reasons I don't understand yet.

Is this something we don't want, or something we do want provided it
can be implemented in a reasonable way?  I have not mapped out how
easy it would be to implement.

I didn't find a discussion of this possibility in the archives, but it
is not the easiest thing to search for.

Cheers,

Jeff



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: pg_system_identifier()
Next
From: Tom Lane
Date:
Subject: Re: Allow child table to be missing nullable column from parent.