Allow child table to be missing nullable column from parent.

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Allow child table to be missing nullable column from parent.
Дата
Msg-id CAMkU=1wJGUnaaksTn7t3cekArVv4LkCfL4RaVkhJbiMb-dTHzQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Allow child table to be missing nullable column from parent.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: pg_system_identifier()
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Allow child table to be missing nullable column from parent.