trigger inheritance

From: "Horst Herb" <hherb(at)malleenet(dot)net(dot)au>
To: <pgsql-interfaces(at)hub(dot)org>
Cc: <pgsql-general(at)hub(dot)org>
Subject: trigger inheritance
Date: 2000-09-17 14:55:55
Message-ID: 004501c020b7$6cef4ce0$0100a8c0@hugin
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces

In Postgres, is it possible to write a (trigger) function for a table "parent" that is inherited automatically by tables "children" ?

If so, how?

And how would this trigger function access _all_ columns in the table "children"?

Example:

create table parent (
id serial,
crc32 int4
);

create function calculate_crc()
returns opaque
as 'BEGIN
new.crc32 = my_external_crc_func();
-- my_external_crc_func must be able to "see" all columns of "new"
END;'
language 'plpgsql';

CREATE TRIGGER inherited
BEFORE INSERT OR UPDATE
ON parent
FOR EACH ROW
EXECUTE PROCEDURE calculate_crc();

create table child (
something text
) inherits (parent);

When I try this, "child" does not seem to inherit the trigger. What's more - I don't know how to let "my_external_crc_func" (loaded dynamically) can "see" all columns in "child".

Who can help me?

Most thankful for any hints,
Horst

Browse pgsql-general by date

  From Date Subject
Next Message K Parker 2000-09-17 16:42:44 Re: LOCK TABLE
Previous Message Peter Eisentraut 2000-09-17 13:02:57 Re: libpq errors when makeing postgres 7.0.2...

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Mount 2000-09-18 10:44:12 RE: jdbc - prepared statement and cvs questions
Previous Message Cesar A. K. Grossmann 2000-09-16 18:12:07 PoPy?