From 04a7e29904a3ae3e43f90e7c36e14c8d6d06c9ca Mon Sep 17 00:00:00 2001 From: mj Date: Thu, 27 Sep 2001 22:23:02 +0000 Subject: [PATCH] Additional changes to the code to get dupetrigger working on PostgreSQL 7.0 --- dbscripts/dupetrigger/dupetrigger.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dbscripts/dupetrigger/dupetrigger.c b/dbscripts/dupetrigger/dupetrigger.c index b00e2bab..201314b6 100755 --- a/dbscripts/dupetrigger/dupetrigger.c +++ b/dbscripts/dupetrigger/dupetrigger.c @@ -15,9 +15,14 @@ #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 -- 2.11.0