Skip to content

Commit 78a6da6

Browse files
committed
Add to inheritance
1 parent 9aab097 commit 78a6da6

File tree

1 file changed

+121
-1
lines changed

1 file changed

+121
-1
lines changed

doc/TODO.detail/inherit renamed to doc/TODO.detail/inheritance

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ From pgsql-general-owner+M2136@hub.org Sat Jun 3 23:31:02 2000
520520
Received: from renoir.op.net (root@renoir.op.net [207.29.195.4])
521521
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id WAA28683
522522
for <pgman@candle.pha.pa.us>; Sat, 3 Jun 2000 22:31:01 -0400 (EDT)
523-
Received: from news.tht.net (news.hub.org [216.126.91.242]) by renoir.op.net (o1/$Revision: 1.14 $) with ESMTP id WAA20977 for <pgman@candle.pha.pa.us>; Sat, 3 Jun 2000 22:05:07 -0400 (EDT)
523+
Received: from news.tht.net (news.hub.org [216.126.91.242]) by renoir.op.net (o1/$Revision: 1.1 $) with ESMTP id WAA20977 for <pgman@candle.pha.pa.us>; Sat, 3 Jun 2000 22:05:07 -0400 (EDT)
524524
Received: from hub.org (majordom@hub.org [216.126.84.1])
525525
by news.tht.net (8.9.3/8.9.3) with ESMTP id VAD35811;
526526
Sat, 3 Jun 2000 21:54:36 -0400 (EDT)
@@ -644,3 +644,123 @@ latter.
644644

645645

646646

647+
From olly@lfix.co.uk Wed Jan 24 16:41:45 2001
648+
Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89])
649+
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id QAA05688
650+
for <pgman@candle.pha.pa.us>; Wed, 24 Jan 2001 16:41:44 -0500 (EST)
651+
Received: from lfix.demon.co.uk ([158.152.59.127] helo=linda.lfix.co.uk)
652+
by anchor-post-31.mail.demon.net with esmtp (Exim 2.12 #1)
653+
id 14LXfg-0007lc-0V; Wed, 24 Jan 2001 21:41:40 +0000
654+
Received: from lfix.co.uk (olly@localhost [127.0.0.1])
655+
by linda.lfix.co.uk (8.11.2/8.11.2/Debian 8.11.2-1) with ESMTP id f0OLfdF12876;
656+
Wed, 24 Jan 2001 21:41:39 GMT
657+
Message-Id: <200101242141.f0OLfdF12876@linda.lfix.co.uk>
658+
X-Mailer: exmh version 2.2 06/23/2000 (debian 2.2-1) with nmh-1.0.4+dev
659+
X-URL: http://www.lfix.co.uk/oliver
660+
X-face: "xUFVDj+ZJtL_IbURmI}!~xAyPC"Mrk=MkAm&tPQnNq(FWxv49R}\>0oI8VM?O2VY+N7@F-
661+
KMLl*!h}B)u@TW|B}6<X<J|}QsVlTi:RA:O7Abc(@D2Y/"J\S,b1!<&<B/J}b.Ii9@B]H6V!+#sE0Q
662+
_+=`K$5TI|4I0-=Cp%pt~L#QYydO'iBXR~\tT?uftep9n9AF`@SzTwsw6uqJ}pL,h(cZi}T#PB"#!k
663+
p^e=Z.K~fuw$l?]lUV)?R]U}l;f*~Ol)#fpKR)Yt}XOr6BI\_Jjr0!@GMnpCTnTym4f;c{;Ms=0{`D
664+
Lq9MO6{wj%s-*N"G,g
665+
To: Bruce Momjian <pgman@candle.pha.pa.us>
666+
cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
667+
PostgreSQL-development <pgsql-hackers@postgresql.org>
668+
Subject: Re: [HACKERS] Re: [GENERAL] child table doesn't inherit PRIMARY KEY?
669+
In-reply-to: Message from Bruce Momjian <pgman@candle.pha.pa.us>
670+
of Wed, 24 Jan 2001 14:31:29 EST. <200101241931.OAA26463@candle.pha.pa.us>
671+
Mime-Version: 1.0
672+
Content-Type: text/plain; charset=us-ascii
673+
Date: Wed, 24 Jan 2001 21:41:39 +0000
674+
From: "Oliver Elphick" <olly@lfix.co.uk>
675+
Status: OR
676+
677+
Bruce Momjian wrote:
678+
>> On Wed, 24 Jan 2001, Bruce Momjian wrote:
679+
680+
>I smell TODO item. In fact, I now see a TODO item:
681+
>
682+
>* Unique index on base column not honored on inserts from inherited table
683+
> INSERT INTO inherit_table (unique_index_col) VALUES (dup) should fail
684+
> [inherit]
685+
>
686+
>So it seems the fact the UNIQUE doesn't apply to the new table is just a
687+
>manifestion of the fact that people expect UNIQUE to span the entire
688+
>inheritance tree. I will add the emails to [inherit] and mark it as
689+
>resolved.
690+
691+
Bruce, could you add this text to TODO.detail on the subject of
692+
inherited constraints. I first sent it on Christmas Eve, and I
693+
think most people were too busy holidaying to comment.
694+
695+
=================================================================
696+
Tom Lane wrote:
697+
>Hm. The short-term answer seems to be to modify the queries generated
698+
>by the RI triggers to say "ONLY foo". I am not sure whether we
699+
>understand the semantics involved in allowing a REFERENCES target to be
700+
>taken as an inheritance tree rather than just one table, but certainly
701+
>the current implementation won't handle that correctly.
702+
703+
May I propose these semantics as a basis for future development:
704+
705+
1. An inheritance hierarchy (starting at any point in a tree) should be
706+
equivalent to an updatable view of all the tables at the point of
707+
reference and below. By default, all descendant tables are combined
708+
with the ancestor for all purposes. The keyword ONLY must be used to
709+
alter this behaviour. Only inherited columns of descendant tables are
710+
visible from higher in the tree. Columns may not be dropped in descendants.
711+
If columns are added to ancestors, they must be inserted correctly in
712+
descendants so as to preserve column ordering and inheritance. If
713+
a column is dropped in an ancestor, it is dropped in all descendants.
714+
715+
2. Insertion into a hierarchy means insertion into the table named in
716+
the INSERT statement; updating or deletion affects whichever table(s)
717+
the affected rows are found in. Updating cannot move a row from one
718+
table to another.
719+
720+
3. Inheritance of a table implies inheriting all its constraints unless
721+
ONLY is used or the constraints are subsequently dropped; again, dropping
722+
operates through all descendant tables. A primary key, foreign key or
723+
unique constraint cannot be dropped or modified for a descendant. A
724+
unique index on a column is shared by all tables below the table for
725+
which it is declared. It cannot be dropped for any descendant.
726+
727+
In other words, only NOT NULL and CHECK constraints can be dropped in
728+
descendants.
729+
730+
In multiple inheritance, a column may inherit multiple unique indices
731+
from its several ancestors. All inherited constraints must be satisfied
732+
together (though check constraints may be dropped).
733+
734+
4. RI to a table implies the inclusion of all its descendants in the
735+
check. Since a referenced column may be uniquely indexed further up
736+
the hierarchy than in the table named, the check must ensure that
737+
the referenced value occurs in the right segment of the hierarchy. RI
738+
to one particular level of the hierarchy, excluding descendants, requires
739+
the use of ONLY in the constraint.
740+
741+
5. Dropping a table implies dropping all its descendants.
742+
743+
6. Changes of permissions on a table propagate to all its descendants.
744+
Permissions on descendants may be looser than those on ancestors; they
745+
may not be more restrictive.
746+
747+
748+
This scheme is a lot more restrictive than C++'s or Eiffel's definition
749+
of inheritance, but it seems to me to make the concept truly useful,
750+
without introducing excessive complexity.
751+
752+
============================================================
753+
754+
--
755+
Oliver Elphick Oliver.Elphick@lfix.co.uk
756+
Isle of Wight http://www.lfix.co.uk/oliver
757+
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
758+
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
759+
========================================
760+
"If anyone has material possessions and sees his
761+
brother in need but has no pity on him, how can the
762+
love of God be in him?"
763+
I John 3:17
764+
765+
766+

0 commit comments

Comments
 (0)