Additional changes to the code to get dupetrigger working on PostgreSQL 7.0
authormj <mj>
Thu, 27 Sep 2001 22:23:02 +0000 (22:23 +0000)
committermj <mj>
Thu, 27 Sep 2001 22:23:02 +0000 (22:23 +0000)
dbscripts/dupetrigger/dupetrigger.c

index b00e2ba..201314b 100755 (executable)
 #include "commands/trigger.h"
 #include "string.h"
 
-extern Datum dupecheck(PG_FUNCTION_ARGS);
 
-PG_FUNCTION_INFO_V1(dupecheck);
+#ifdef PG71
+       extern Datum dupecheck(PG_FUNCTION_ARGS);
+       PG_FUNCTION_INFO_V1(dupecheck);
+#else
+       extern Datum dupecheck(void);
+#endif
+
 
 
 
@@ -101,11 +106,13 @@ static u_long crc32(u_char *buf, unsigned len)
 
 
 
+#ifdef PG71
 Datum dupecheck(PG_FUNCTION_ARGS)
 {
-#ifdef PG71
        TriggerData *trigdata = (TriggerData *) fcinfo->context;
 #else
+Datum dupecheck(void)
+{
        TriggerData *trigdata = CurrentTriggerData;
 #endif
        TupleDesc       tupdesc;
@@ -163,6 +170,7 @@ Datum dupecheck(PG_FUNCTION_ARGS)
        if (rowstring == NULL)
        {
                // Big problem.
+               SPI_finish();
                return PointerGetDatum(NULL);
        }
 
@@ -183,6 +191,7 @@ Datum dupecheck(PG_FUNCTION_ARGS)
        if (query == NULL)
        {
                // Big problem
+               SPI_finish();
                return PointerGetDatum(NULL);
        }
        
@@ -193,6 +202,7 @@ Datum dupecheck(PG_FUNCTION_ARGS)
        if ((ret == SPI_OK_SELECT) && (num > 0))
        {
                elog(NOTICE, "dupecheck: UBD detected, dupe dropped");
+               SPI_finish();
                return PointerGetDatum(NULL);
        }
        else