(and change pathnames and PGVERSION if neccessary).
# make
-(This makes the trigger binary and places it in /tmp with permissions 644)
+(This makes the trigger binary and places it in INSTALLDIR with permissions 644)
+
+# edit postgresql.script
+(And change the path to dupetrigger.so to INSTALLDIR)
# psql -U postgres Mir < postgresql.script
(This installs the the trigger binary and creates a new trigger.)
bool isnull,
debug_on;
int ret = 0, i, fnumber;
- long rowstrlen = 0,
+ u_long rowstrlen = 0,
crc;
char **items, // will point to a malloc'ed array
*rowstring,
{
// Big problem
free(items);
+ free(rowstring);
SPI_finish();
return PointerGetDatum(NULL);
}
if ((ret == SPI_OK_SELECT) && (num > 0) && !(TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)))
{
elog(NOTICE, "dupecheck: UBD in %s detected, dupe dropped", relation);
- free(items);
- SPI_finish();
- return PointerGetDatum(NULL);
+ rettuple = NULL; // reject operation
}
else
{
rettuple = SPI_modifytuple(trigdata->tg_relation, rettuple, 1, &attnum, &value, &nulls);
}
+ free(items);
+ free(rowstring);
+ free(query);
SPI_finish();
return PointerGetDatum(rettuple);
}