Corrected Postgres 7.0 support (hopefully).
[mir.git] / dbscripts / dupetrigger / dupetrigger.c
index 11315c6..b00e2ba 100755 (executable)
@@ -103,7 +103,11 @@ static u_long crc32(u_char *buf, unsigned len)
 
 Datum dupecheck(PG_FUNCTION_ARGS)
 {
+#ifdef PG71
        TriggerData *trigdata = (TriggerData *) fcinfo->context;
+#else
+       TriggerData *trigdata = CurrentTriggerData;
+#endif
        TupleDesc       tupdesc;
        HeapTuple       rettuple;
        bool            isnull;
@@ -116,11 +120,13 @@ Datum dupecheck(PG_FUNCTION_ARGS)
                *rowstring,
                *query;
        
-
        /* Make sure trigdata is pointing at what I expect */
+#ifdef PG70
+       if (!CurrentTriggerData)
+#else          
        if (!CALLED_AS_TRIGGER(fcinfo))
+#endif 
                elog(ERROR, "dupecheck: not fired by trigger manager");
-       
        /* tuple to return to Executor */
        if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
                rettuple = trigdata->tg_newtuple;