The docs suggest that this:
/* Get number of tuples in relation */ ret = SPI_exec("select count(*) from ttest", 0);
if (ret < 0) elog(NOTICE, "trigf (fired %s): SPI_exec returned %d",
when, ret);
i = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc,
1, &isnull); elog (NOTICE, "trigf(fired %s): there are %d tuples in ttest",
when, i);
When it should be:
pi = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc,
1, &isnull); elog (NOTICE, "trigf(fired %s): there are %d tuples in ttest",
when, *pi);