Thread: trigger inheritance

trigger inheritance

From
fcanedo@soneramail.nl
Date:
Hi,

I'm new to PostgreSQL and am currently trying to figure out the
object-oriented stuff.

When I make a new table (B) that inherits from another table (A), I would
expect that B inherits the triggers (among other things) from A. It does
not! In the reference manual (CREATE TABLE) it says "Postgres
automatically allows the created table to inherit functions on tables
above it in the inheritance hierarchy."

Since functions don't belong to tables (correct me if I'm wrong) I would
believe triggers are ment here!

So my question is:

Is 'trigger inheritance' available and functional in PostgreSQL 7.1?
If so, how do I turn this on?
If not, is this being worked on (according to the todo, *not*)? Do I need
to take this to the hackers/development list?



For those who are curious:

I solved my problem by manually adding a
trigger for B, that calls the same function that the trigger for A
calls. If necessary I add a new trigger for B (with specific
functionality for B) after adding the "inherited" trigger.
But this is extra work and administration with all it's extra problems.



TIA,

Francisco


Re: trigger inheritance

From
Tom Lane
Date:
fcanedo@soneramail.nl writes:
> In the reference manual (CREATE TABLE) it says "Postgres
> automatically allows the created table to inherit functions on tables
> above it in the inheritance hierarchy."

> Since functions don't belong to tables (correct me if I'm wrong)

Okay, you're wrong.

What that sentence is referring to is the fact that functions declared
as taking table row types can be applied to rows of derived tables as
well as the one they were originally declared against.  (I'm not sure
how well this actually works in cases involving multiple inheritance
or ALTER TABLE, but in simple cases it should be OK.)

Triggers and indexes are not inherited.  Yes, that's probably a bug.

            regards, tom lane

Re: trigger inheritance

From
David Wheeler
Date:
On Thu, 5 Jul 2001, Tom Lane wrote:

> Triggers and indexes are not inherited.  Yes, that's probably a bug.

Hmmm...what are the chances that this issue will be corrected in a future
version? Is it on the TODO list?

Thanks,

David

--
David Wheeler                                         AIM: dwTheory
David@Wheeler.net                                     ICQ: 15726394
                                                   Yahoo!: dew7e
                                                   Jabber: Theory@jabber.org