pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: nitinmn@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8116: create trigger after insert fails if procedure being executed is having error
Date: Thu, 25 Apr 2013 13:52:36 +0000
Message-ID: <E1UVMbE-0003cv-7V@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      8116
Logged by:          CREATE TRIGGER AFTER INSERT FAILS
Email address:      nitinmn@gmail.com
PostgreSQL version: 9.1.7
Operating system:   WINDOWS , UNIX
Description:        

when we create a trigger for a table which basically runs triggers a
procedure after insert.now if the procedure has some error when executing ,
the insert also fails, But ideally since this trigger is defined after
insert , the insert should have been successful.
eg
CREATE OR REPLACE FUNCTION insert_send_mail_function()
RETURNS "trigger" AS
$BODY$
use Mail::Sendmail;

$str = substr trim($_TD->{new}{url}),3;
$subject = "Login Alert : ".$_TD->{new}{username}.", ";
message  = "URL accessed: ".$_TD->{new}{url}."\n";
%mail = ( From => $_[0], To => $_[1], Subject => $subject , Message =>
$message);

sendmail(%mail) or die $Mail::Sendmail::error;
return undef;
$BODY$
LANGUAGE 'plperlu' VOLATILE;


CREATE TRIGGER  insert_send_mail_trigger
AFTER INSERT ON user_log
FOR EACH ROW
EXECUTE PROCEDURE insert_send_mail_function('abc@gmail.com',
'ab1213@gmail.com');

because there is a trim function , thought the procedure gets parsed
successfully , while runtime it fails , but that should not stop insert
failure since it is only after insert.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



Message-ID: <E1UVMbE-0003cv-7V@wrigleys.postgresql.org>
Permalink:  ../E1UVMbE-0003cv-7V@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1UVMbE-0003cv-7V@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: nitinmn@gmail.com
  Subject: Re: BUG #8116: create trigger after insert fails if procedure being executed is having error
  In-Reply-To: <E1UVMbE-0003cv-7V@wrigleys.postgresql.org>
  References: <E1UVMbE-0003cv-7V@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox