Prior to this prohibition, such a trigger caused a crash.
Thomas Munro, per a report from Neha Sharma. I added a
regression test.
Discussion: http://postgr.es/m/CAEepm=0VR5W-N38eTkO_FqJbGqQ_ykbBRmzmvHyxDhy1p=0Csw@mail.gmail.com
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("transition table name can only be specified for an AFTER trigger")));
+ if (TRIGGER_FOR_TRUNCATE(tgtype))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("TRUNCATE triggers with transition tables are not supported")));
+
if (tt->isNew)
{
if (!(TRIGGER_FOR_INSERT(tgtype) ||
RETURN NULL;
END;
$$;
+-- should fail, TRUNCATE is not compatible with transition tables
+CREATE TRIGGER alter_table_under_transition_tables_upd_trigger
+ AFTER TRUNCATE OR UPDATE ON alter_table_under_transition_tables
+ REFERENCING OLD TABLE AS d NEW TABLE AS i
+ FOR EACH STATEMENT EXECUTE PROCEDURE
+ alter_table_under_transition_tables_upd_func();
+ERROR: TRUNCATE triggers with transition tables are not supported
+-- should work
CREATE TRIGGER alter_table_under_transition_tables_upd_trigger
AFTER UPDATE ON alter_table_under_transition_tables
REFERENCING OLD TABLE AS d NEW TABLE AS i
END;
$$;
+-- should fail, TRUNCATE is not compatible with transition tables
+CREATE TRIGGER alter_table_under_transition_tables_upd_trigger
+ AFTER TRUNCATE OR UPDATE ON alter_table_under_transition_tables
+ REFERENCING OLD TABLE AS d NEW TABLE AS i
+ FOR EACH STATEMENT EXECUTE PROCEDURE
+ alter_table_under_transition_tables_upd_func();
+
+-- should work
CREATE TRIGGER alter_table_under_transition_tables_upd_trigger
AFTER UPDATE ON alter_table_under_transition_tables
REFERENCING OLD TABLE AS d NEW TABLE AS i