pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Horst Herb <hherb@malleenet.net.au>
To: pgsql-interfaces@hub.org
Cc: pgsql-general@hub.org
Subject: trigger inheritance
Date: Mon, 18 Sep 2000 00:55:55 +1000
Message-ID: <004501c020b7$6cef4ce0$0100a8c0@hugin> (raw)

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




Message-ID: <004501c020b7$6cef4ce0$0100a8c0@hugin>
Permalink:  ../004501c020b7$6cef4ce0$0100a8c0@hugin/
Also on:    postgresql.org/message-id/004501c020b7$6cef4ce0$0100a8c0@hugin

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: hherb@malleenet.net.au, pgsql-interfaces@hub.org, pgsql-general@hub.org
  Subject: Re: trigger inheritance
  In-Reply-To: <004501c020b7$6cef4ce0$0100a8c0@hugin>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox