diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c index 4552fc3b59e99f6ea212cbd28760369519f94c44..9b38493a3323f672d2d20bb95b97f848a7afa76b 100644 --- a/contrib/spi/autoinc.c +++ b/contrib/spi/autoinc.c @@ -35,10 +35,10 @@ autoinc(PG_FUNCTION_ARGS) if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */ elog(ERROR, "not fired by trigger manager"); - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */ - elog(ERROR, "cannot process STATEMENT events"); - if (TRIGGER_FIRED_AFTER(trigdata->tg_event)) + elog(ERROR, "must be fired for row"); + if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event)) /* internal error */ elog(ERROR, "must be fired before event"); diff --git a/contrib/spi/insert_username.c b/contrib/spi/insert_username.c index da6764faf64e6c55c5cda39ede6df078bd283e28..18a13344cf175bbdaac8bb5c35391eb4f7beb44d 100644 --- a/contrib/spi/insert_username.c +++ b/contrib/spi/insert_username.c @@ -38,10 +38,10 @@ insert_username(PG_FUNCTION_ARGS) if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */ elog(ERROR, "insert_username: not fired by trigger manager"); - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */ - elog(ERROR, "insert_username: cannot process STATEMENT events"); - if (TRIGGER_FIRED_AFTER(trigdata->tg_event)) + elog(ERROR, "insert_username: must be fired for row"); + if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event)) /* internal error */ elog(ERROR, "insert_username: must be fired before event"); diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c index e90c0b5cc254f42b53b0dd1f9da57f5299b64bc5..9a1addb78ad838514573039af44cb2e36bf7a5cd 100644 --- a/contrib/spi/moddatetime.c +++ b/contrib/spi/moddatetime.c @@ -43,17 +43,17 @@ moddatetime(PG_FUNCTION_ARGS) /* internal error */ elog(ERROR, "moddatetime: not fired by trigger manager"); - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */ - elog(ERROR, "moddatetime: cannot process STATEMENT events"); + elog(ERROR, "moddatetime: must be fired for row"); - if (TRIGGER_FIRED_AFTER(trigdata->tg_event)) + if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event)) /* internal error */ elog(ERROR, "moddatetime: must be fired before event"); if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) /* internal error */ - elog(ERROR, "moddatetime: must be fired before event"); + elog(ERROR, "moddatetime: cannot process INSERT events"); else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) rettuple = trigdata->tg_newtuple; else diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c index cbd08d491db8a79f88ac64c092741eff3d77fc77..36f9ee421e7ad617a84319f9f5a552570dce0e0e 100644 --- a/contrib/spi/refint.c +++ b/contrib/spi/refint.c @@ -79,9 +79,9 @@ check_primary_key(PG_FUNCTION_ARGS) elog(ERROR, "check_primary_key: not fired by trigger manager"); /* Should be called for ROW trigger */ - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */ - elog(ERROR, "check_primary_key: cannot process STATEMENT events"); + elog(ERROR, "check_primary_key: must be fired for row"); /* If INSERTion then must check Tuple to being inserted */ if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) @@ -279,9 +279,9 @@ check_foreign_key(PG_FUNCTION_ARGS) elog(ERROR, "check_foreign_key: not fired by trigger manager"); /* Should be called for ROW trigger */ - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */ - elog(ERROR, "check_foreign_key: cannot process STATEMENT events"); + elog(ERROR, "check_foreign_key: must be fired for row"); /* Not should be called for INSERT */ if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c index 8bae3131dcfc142654354cd61760e19eb8f8609b..14621244a9801bad146ce94daa3cfc8d8c0275eb 100644 --- a/contrib/spi/timetravel.c +++ b/contrib/spi/timetravel.c @@ -118,11 +118,11 @@ timetravel(PG_FUNCTION_ARGS) elog(ERROR, "timetravel: not fired by trigger manager"); /* Should be called for ROW trigger */ - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) - elog(ERROR, "timetravel: cannot process STATEMENT events"); + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) + elog(ERROR, "timetravel: must be fired for row"); /* Should be called BEFORE */ - if (TRIGGER_FIRED_AFTER(trigdata->tg_event)) + if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event)) elog(ERROR, "timetravel: must be fired before event"); /* INSERT ? */ diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c index 399fee85af86d8f19d2e17f79bd0cb77c675558f..769509772a11cdc0ae9e86b58041ac89107f19eb 100644 --- a/src/backend/utils/adt/tsvector_op.c +++ b/src/backend/utils/adt/tsvector_op.c @@ -1257,9 +1257,9 @@ tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column) elog(ERROR, "tsvector_update_trigger: not fired by trigger manager"); trigdata = (TriggerData *) fcinfo->context; - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) - elog(ERROR, "tsvector_update_trigger: can't process STATEMENT events"); - if (TRIGGER_FIRED_AFTER(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) + elog(ERROR, "tsvector_update_trigger: must be fired for row"); + if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event)) elog(ERROR, "tsvector_update_trigger: must be fired BEFORE event"); if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 6601320de30c777d8dc147c7e0f7dcd1a47a9b8e..e2b5f77c9d92032912eb0f33834206770282f70f 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -526,7 +526,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func, rec_old->tupdesc = trigdata->tg_relation->rd_att; rec_old->freetupdesc = false; - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) { /* * Per-statement triggers don't use OLD/NEW variables @@ -715,7 +715,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func, * attributes don't have the correct atttypmod's length. It's up to the * trigger's programmer to ensure that this doesn't happen. Jan */ - if (estate.retisnull || TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) + if (estate.retisnull || !TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) rettup = NULL; else { diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index 6e35637daf2bb3e79a434c0d940bb8aa7ad3b0c3..4c53987fa4a87ac83a70b4b8a4231b59e1f78368 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -841,7 +841,6 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r Py_DECREF(plttableschema); pfree(stroid); - if (TRIGGER_FIRED_BEFORE(tdata->tg_event)) pltwhen = PyString_FromString("BEFORE"); else if (TRIGGER_FIRED_AFTER(tdata->tg_event)) diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 8b0f9f14f3568d97e65b267117aadeb501af4913..8e4286a643b2331ed98068a6f0d052ebdacb2dc2 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -487,9 +487,9 @@ ttdummy(PG_FUNCTION_ARGS) if (!CALLED_AS_TRIGGER(fcinfo)) elog(ERROR, "ttdummy: not fired by trigger manager"); - if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) - elog(ERROR, "ttdummy: cannot process STATEMENT events"); - if (TRIGGER_FIRED_AFTER(trigdata->tg_event)) + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) + elog(ERROR, "ttdummy: must be fired for row"); + if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event)) elog(ERROR, "ttdummy: must be fired before event"); if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) elog(ERROR, "ttdummy: cannot process INSERT event");