Thread: BUG #8116: create trigger after insert fails if procedure being executed is having error
BUG #8116: create trigger after insert fails if procedure being executed is having error
From
nitinmn@gmail.com
Date:
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 =3D substr trim($_TD->{new}{url}),3; $subject =3D "Login Alert : ".$_TD->{new}{username}.", "; message =3D "URL accessed: ".$_TD->{new}{url}."\n"; %mail =3D ( From =3D> $_[0], To =3D> $_[1], Subject =3D> $subject , Message= =3D> $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.