diff options
Diffstat (limited to 'contrib/lo/lo.c')
-rw-r--r-- | contrib/lo/lo.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c index 9dbbbcebd2..4dee64724d 100644 --- a/contrib/lo/lo.c +++ b/contrib/lo/lo.c @@ -18,10 +18,6 @@ PG_MODULE_MAGIC; #define atooid(x) ((Oid) strtoul((x), NULL, 10)) -/* forward declarations */ -Datum lo_manage(PG_FUNCTION_ARGS); - - /* * This is the trigger that protects us from orphaned large objects */ @@ -40,7 +36,12 @@ lo_manage(PG_FUNCTION_ARGS) HeapTuple trigtuple; /* The original value of tuple */ if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */ - elog(ERROR, "not fired by trigger manager"); + elog(ERROR, "%s: not fired by trigger manager", + trigdata->tg_trigger->tgname); + + if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */ + elog(ERROR, "%s: must be fired for row", + trigdata->tg_trigger->tgname); /* * Fetch some values from trigdata @@ -50,6 +51,10 @@ lo_manage(PG_FUNCTION_ARGS) tupdesc = trigdata->tg_relation->rd_att; args = trigdata->tg_trigger->tgargs; + if (args == NULL) /* internal error */ + elog(ERROR, "%s: no column name provided in the trigger definition", + trigdata->tg_trigger->tgname); + /* tuple to return to Executor */ if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) rettuple = newtuple; @@ -63,7 +68,8 @@ lo_manage(PG_FUNCTION_ARGS) attnum = SPI_fnumber(tupdesc, args[0]); if (attnum <= 0) - elog(ERROR, "column \"%s\" does not exist", args[0]); + elog(ERROR, "%s: column \"%s\" does not exist", + trigdata->tg_trigger->tgname, args[0]); /* * Handle updates |