X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7C746D1B20D for ; Tue, 18 May 2004 13:19:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 70110-08 for ; Tue, 18 May 2004 13:19:25 -0300 (ADT) Received: from mailhost1.os.kcp.com (mailhost1.os.kcp.com [198.124.201.31]) by svr1.postgresql.org (Postfix) with ESMTP id D237FD1B3C6 for ; Tue, 18 May 2004 13:19:24 -0300 (ADT) Message-ID: <40AA3784.4060303@kcp.com> Date: Tue, 18 May 2004 11:19:16 -0500 From: hook User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: I'm baffled Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-MessageInspectorSig: b7b2dc1c4e25a25b7c53fe164567bf00 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/157 X-Sequence-Number: 17871 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 # include 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); }