I'm baffled - Mailing list pgsql-sql

From hook
Subject I'm baffled
Date
Msg-id 40AA3784.4060303@kcp.com
Whole thread Raw
List pgsql-sql
I have a couple of 'c' object files that send mail when ever there in an 
insert or delete to specified tables.
The problem is that I get the mail message even if the insert fails!

what am I doing wrong?


thanks


The function;   create function insert_r1(text, text, text, text) returns int4        as '/var/pgsql/insert_r1.so'
LANGUAGE'c' ;
 
the rule: create rule partmaster_I as   on insert to partmaster      do select insert_R1(new.afpn,
'partmaster(insert)','','')as answer;
 

the 'c' module:
# include "internal/postgres_fe.h"
# include <string.h>
# include <unistd.h>

int insert_r1(text *arg1, text *arg2, text *arg3, text *arg4)
{ char *table, *key, *mesg, *user; char host[20]; FILE *fp; arg1->vl_dat[arg1->vl_len - VARHDRSZ] = '\0';
arg2->vl_dat[arg2->vl_len- VARHDRSZ] = '\0'; arg3->vl_dat[arg3->vl_len - VARHDRSZ] = '\0'; arg4->vl_dat[arg4->vl_len -
VARHDRSZ]= '\0';
 
 key   = strdup(arg1->vl_dat); table = strdup(arg2->vl_dat); mesg  = strdup(arg3->vl_dat); user  =
strdup(arg4->vl_dat);
 gethostname(host, sizeof(host)); system(" cat /tmp/newMsg >> /tmp/newMsg.arc"); if ( (fp = fopen("/tmp/newMsg", "w+")
)== NULL)   return(-1);   fprintf(fp, "%s:: %s:(%s) Approval requested  - %s   %s\n", 
 
host,table,key,mesg,user);     fclose (fp);
   system("Mail -s \"Bmss \" hook@kcp.com     < /tmp/newMsg"); return(0);
}



pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Very slow search using basic pattern matching
Next
From: Karsten Hilbert
Date:
Subject: Re: Very slow search using basic pattern matching