diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml
index 8d7574319f..ecb1f56cbf 100644
--- a/doc/src/sgml/ref/create_trigger.sgml
+++ b/doc/src/sgml/ref/create_trigger.sgml
@@ -183,7 +183,8 @@ CREATE TRIGGER name { BEFORE | AFTE
To create a trigger on a table, the user must have the
- TRIGGER privilege on the table.
+ TRIGGER privilege on the table. The user must
+ also have EXECUTE privilege on the trigger function.
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index e3c771a933..cadca5c01b 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -161,6 +161,10 @@ CreateTrigger(CreateTrigStmt *stmt, Oid constraintOid, bool checkPermissions)
* Find and validate the trigger function.
*/
funcoid = LookupFuncName(stmt->funcname, 0, fargtypes, false);
+ aclresult = pg_proc_aclcheck(funcoid, GetUserId(), ACL_EXECUTE);
+ if (aclresult != ACLCHECK_OK)
+ aclcheck_error(aclresult, ACL_KIND_PROC,
+ NameListToString(stmt->funcname));
funcrettype = get_func_rettype(funcoid);
if (funcrettype != TRIGGEROID)
{