I'm using PostgreSQL. I have a table that I have partitioned into three sub-tables - and as far as I can tell, this all works correctly. Rows are correctly inserted into the appropriate partition and the master table remains empty.

My problem is that one of the triggers on the master table is no longer run on insert or update. Other triggers are run correctly and this trigger worked correctly prior to partitioning.

I suspected this might be similar to constraints and indexes and the trigger needed to be applied to child tables, however this doesn't work either.

Other triggers work, and if they are run alphabetically as the documentation suggests, all should be run before the partition-finding trigger.

The trigger that is causing me grief:

~~~
CREATE FUNCTION set_expiry_timestamp() RETURNS trigger AS $BODY$
BEGIN
    -- Don't re-generate if the timeleft value has not changed
    IF (TG_OP = 'UPDATE') THEN
        IF OLD.expires IS NOT NULL AND OLD.timeleft = NEW.timeleft THEN
            RETURN NEW;
        END IF;
    END IF;

    IF (NEW.timeleft = 'SHORT') THEN
        NEW.expires := NEW.updated + interval '30 minutes';
    ELSIF (NEW.timeleft = 'MEDIUM') THEN
        NEW.expires := NEW.updated + interval '2 hours';
    ELSIF (NEW.timeleft = 'LONG') THEN
        NEW.expires := NEW.updated + interval '12 hours';
    ELSIF (NEW.timeleft = 'VERY_LONG') THEN
        NEW.expires := NEW.updated + interval '48 hours';
    ELSE
        RAISE EXCEPTION 'timeleft was unrecognised. Expected SHORT, MEDIUM, LONG or VERY_LONG.';
    END IF;
    RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql;


CREATE TRIGGER set_expiry
AFTER INSERT OR UPDATE ON auction
FOR EACH ROW EXECUTE PROCEDURE set_expiry_timestamp();
~~~

Query expected to fire the trigger:

    INSERT INTO auction (created, timeleft) VALUES (NOW(), 'SHORT');

`updated` is set in a `BEFORE INSERT/UPDATE` trigger. However, it still doesn't fire when it is supplied.

Any suggestions?