I need a trigger to cause a reindex (index is on an immutable function) I define the function as
CREATE FUNCTION "TEST".triggerFuncTest()
RETURNS TRIGGER
AS $$
BEGIN
REINDEX INDEX "TEST"."MyIndex";
RETURN NULL;
END $$ LANGUAGE plpgsql;
with the trigger
CREATE CONSTRAINT TRIGGER triggerTest
AFTER INSERT OR UPDATE OF indexes OR DELETE ON "TEST"."MyTable"
DEFERRABLE INITIALLY DEFERRED
FOR EACH STATEMENT
EXECUTE PROCEDURE "TEST".triggerFuncTest();
Which gives
ERROR: syntax error at or near "STATEMENT"
However the trigger will be created if I remove CONSTRAINT and DEFERRABLE INITIALLY DEFERRED, however this will cause an exception when triggered.