Re: [QUESTIONS] inheritance questions - Mailing list pgsql-hackers

From Oliver Elphick
Subject Re: [QUESTIONS] inheritance questions
Date
Msg-id 199805071138.MAA05000@linda.lfix.co.uk
Whole thread Raw
Responses Re: [QUESTIONS] inheritance questions
List pgsql-hackers
Olivier Caron wrote:
  >in the user's guide (chapter _ inheritance), i see :
  >-----------------------------------------------------------
  >select * from cities *
  >
  >here the * after cities indicates that the query should be run over cities
  >and all classes below cities in the inheritance hierarchy.
  >Many of the commands that we have already discussed -- select, update
  >and delete -- support this * notation, as do others, like alter
  >-----------------------------------------------------------
  >
  >i don't succedeed in  to execute update or delete with this * notation,

The ramifications of inheritance are not well thought out in PostgreSQL.

Consider:

       cities -----+---- capital_cities ----- megacities
                   ¦
                   +---- regional_centres
                   ¦
                   +---- small_towns

At the moment, a subclass inherits columns and _some_ constraints from
its parents - it inherits check constraints but not primary key constraints.
I don't know what behaviour is planned for foreign key constraints.
It is possible, with multiple inheritance, to inherit mutually-inconsistent
check constraints but there is no way to undefine or redefine inherited
constraints.

You can do `select * from cities *', but you cannot do an insert, delete
or update.  In other words, the inheritance tree as a whole is regarded as
a read-only entity.

The inability to do insert seems reasonable, because there
would not be any safe way of knowing which table in the inheritance
tree was intended.  However, update and delete could be expected to
work.  I suspect that no-one ever asked for the facility!

I have previously suggested some syntax for specifying the inheritance
of constraints more precisely.  It looks as if there should also be a
means of saying whether a descendant class should be included in
operations on multiple rows - I don't think it should be a facility that
operates automatically.

Is any of the developers an expert on the inheritance features? or is
this something that no-one has yet taken up?

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "If it is possible, as much as it depends on you, live
      peaceably with all men."        Romans 12:18



pgsql-hackers by date:

Previous
From: Michael Meskes
Date:
Subject: Decicision needed for connect statement
Next
From: "Thomas G. Lockhart"
Date:
Subject: Re: [QUESTIONS] inheritance questions