Thread: If table have an inclusion with LIKE what happens to triggers?
Hello,
If I have a small table with common fields(
)
Then I put som triggers on those fields
CREATE OR REPLACE FUNCTION update_modified_timestamp_function() RETURNS trigger AS
$$
BEGIN
NEW.modified_timestamp := CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$
LANGUAGE plpgsql VOLATILE;
$$
BEGIN
NEW.modified_timestamp := CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$
LANGUAGE plpgsql VOLATILE;
CREATE TRIGGER common_field_update_triger
BEFORE UPDATE ON rscada.common_fields
FOR EACH ROW
EXECUTE PROCEDURE update_modified_timestamp_function();
BEFORE UPDATE ON rscada.common_fields
FOR EACH ROW
EXECUTE PROCEDURE update_modified_timestamp_function();
And then include this in another table
CREATE TABLE venue
(
name varchar default '',
LIKE common_fields
)
The triggers is not executed.
Is there any way to inherit also
the triggers from the common_field table?
Or must I place triggers on all tables?
/Cordially yours
Is there any way to inherit alsothe triggers from the common_field table?
No
Or must I place triggers on all tables?
Yes
The docs cover what is able to be copied and triggers are not mentioned.
Mostly column-related things are copied, not table-related things (e.g., table comments, triggers, policies)
I suspect its mostly a lack of need warranting the effort than any fundamental design reason.
David J.