Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33773af

Browse files
committed
Generate distinct error messages for trigger function not found
and trigger function found but returns wrong type.
1 parent 443c08a commit 33773af

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/commands/trigger.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,12 @@ CreateTrigger(CreateTrigStmt *stmt)
138138
PointerGetDatum(fargtypes),
139139
0);
140140
if (!HeapTupleIsValid(tuple) ||
141-
((Form_pg_proc) GETSTRUCT(tuple))->prorettype != 0 ||
142141
((Form_pg_proc) GETSTRUCT(tuple))->pronargs != 0)
143-
elog(ERROR, "CreateTrigger: function %s () does not exist", stmt->funcname);
144-
142+
elog(ERROR, "CreateTrigger: function %s() does not exist",
143+
stmt->funcname);
144+
if (((Form_pg_proc) GETSTRUCT(tuple))->prorettype != 0)
145+
elog(ERROR, "CreateTrigger: function %s() must return OPAQUE",
146+
stmt->funcname);
145147
if (((Form_pg_proc) GETSTRUCT(tuple))->prolang != ClanguageId)
146148
{
147149
HeapTuple langTup;

0 commit comments

Comments
 (0)