Trigger uses a procedure or a function?



  • PostgreSQL version 10 and before use the term "Trigger Procedure" ( https://www.postgresql.org/docs/10/plpgsql-trigger.html ). But later versions use the term "Trigger Function".

    What is the reason for changing that term?



  • https://www.postgresql.org/docs/current/sql-createtrigger.html have always been using functions, not procedures. Unfortunately, the terminology is fuzzy, many use "stored procedure" as umbrella term for both functions and procedures.

    Thus the widespread misnomer "procedure" had crept in, spreading even to the syntax of CREATE TRIGGER ... EXECUTE PROCEDURE where a function name is required. That was a merely academic nuisance while Postgres only had functions, not procedures. See:

    • https://dba.stackexchange.com/questions/2357/what-are-the-differences-between-stored-procedures-and-stored-functions/2381#2381

    Postgres 11 eventually added true https://www.postgresql.org/docs/current/sql-createprocedure.html , which elevated that misleading terminology to a real problem. So the manual fixed its wording, and the proper syntax variant CREATE TRIGGER ... EXECUTE FUNCTION was added, which is preferred going forward. The old variant is still accepted for compatibility reasons - and will be for quite a while longer until that can finally be dropped for good.

    Related:

    • https://dba.stackexchange.com/questions/251189/trigger-function-does-not-exist-but-i-am-pretty-sure-it-does/255319#255319



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2