In BEFORE UPDATE TRIGGER, how do I prevent changing nothing but timestamp? I'm working on a trigger, and part of its functionality is to prevent UPDATE if the only field being updated is the timestamp field.

My current solution is like this:

CREATE OR REPLACE FUNCTION verify() RETURNS TRIGGER AS $verify$
    BEGIN
        IF (TG_OP = 'UPDATE') THEN
            IF ((OLD.first, OLD.middle, OLD.last, OLD.address, OLD.phone, OLD.notes)
                IS DISTINCT FROM
                (NEW.first, NEW.middle, NEW.last, NEW.address, NEW.phone, NEW.notes)) THEN
                    RETURN NEW;
            ELSE
                    RAISE NOTICE 'Must change something besides timestamp.';
                    RETURN NULL;
            END IF;
        END IF;
        RETURN NEW;
    END;
$verify$ LANGUAGE plpgsql;

DROP TRIGGER IF EXISTS verify ON test;
CREATE TRIGGER verify BEFORE INSERT OR UPDATE ON test
    FOR EACH ROW EXECUTE PROCEDURE verify();


It works, but - if I add a field to the table, I would have to update the trigger, and that seems convoluted.

Is it possible to simplify the condition?
Make a copy of old, update the timestamp and compare it with new.

CREATE OR REPLACE FUNCTION verify() RETURNS TRIGGER AS $verify$
    DECLARE
        rec record;
    BEGIN
        IF (TG_OP = 'UPDATE') THEN
            rec=old;
            rec.timestamp = NEW.timestamp;
            IF rec IS DISTINCT FROM NEW THEN
                    RETURN NEW;
            ELSE
                    RAISE WARNING 'Must change something besides timestamp.';
                    RETURN NULL;
            END IF;
        END IF;
        RETURN NEW;
    END;
$verify$ LANGUAGE plpgsql;


(edit: thanks @ Granny Aching)

If you don't need OLD later in the trigger you can modify it without harm.

CREATE OR REPLACE FUNCTION verify() RETURNS TRIGGER AS $verify$
    BEGIN
        IF (TG_OP = 'UPDATE') THEN
            OLD.timestamp = NEW.timestamp;
            IF  OLD IS DISTINCT FROM NEW THEN
                    RETURN NEW;
            ELSE
                    RAISE WARNING 'Must change something besides timestamp.';
                    RETURN NULL;
            END IF;
        END IF;
        RETURN NEW;
    END;
$verify$ LANGUAGE plpgsql;