diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c
index 9dbbbce..2b9477a 100644
--- a/contrib/lo/lo.c
+++ b/contrib/lo/lo.c
@@ -50,6 +50,13 @@ lo_manage(PG_FUNCTION_ARGS)
 	tupdesc = trigdata->tg_relation->rd_att;
 	args = trigdata->tg_trigger->tgargs;
 
+	if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))     /* internal error */
+		elog(ERROR, "not fired by a for each row trigger");
+
+	if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event))      /* internal error */
+		elog(ERROR, "not fired as a before trigger");
+
+
 	/* tuple to return to Executor */
 	if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
 		rettuple = newtuple;
@@ -59,6 +66,9 @@ lo_manage(PG_FUNCTION_ARGS)
 	/* Are we deleting the row? */
 	isdelete = TRIGGER_FIRED_BY_DELETE(trigdata->tg_event);
 
+	if (args == NULL)                                  /* internal error */
+		elog (ERROR, "no column name provided in the trigger definition");
+
 	/* Get the column we're interested in */
 	attnum = SPI_fnumber(tupdesc, args[0]);
 
