Re: making a trigger to a system call to a shell script

From: Alejandro Fernandez <ale(at)e-group(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: making a trigger to a system call to a shell script
Date: 2002-05-03 07:51:34
Message-ID: 20020503095134.62de0e19.ale@e-group.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the suggestions. I put it in /usr/lib/pgsql and now it's getting taken. I used the command

create function alertme(varchar(100)) returns int as '/usr/lib/pgsql/alertme.so' language 'C';

This seemed to work: it returned "CREATE"

Then commands like:
select alertme('This is not an exercise!');

would send me an email, although there seems to be a problem with the types, because it takes a char * as an argument, but I couldn't find a list of types for postgresql functions, so the email it sends always contains one symbol (pi for strings and 3/4ths symbol for integers or chars), can't cut and paste it to show...).

Anyway, last step was to create a trigger so that I could monitor changes to my table remotely:

create trigger trigger_alertme
before insert or update on mytable for each row execute procedure alertme('blablabla');

And this will not work: it returns:

ERROR: CreateTrigger: function alertme() does not exist

Any idea where to go from here?

Thanks again! - I think this is quite a frequent wish by many people, as I've seen the question "how do I trigger an outside script" crop up unanswered quite a few times in the archives. I did get the email about the sourceforge project - thanks a lot! - but I'm so far into this, I'd like to get to the bottom of it first! (Yes, and meanwhile I'm using cron - thanks!).

Ale

On Thu, 02 May 2002 17:46:13 -0400
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Alejandro Fernandez <ale(at)e-group(dot)org> writes:
> > and it says "stat failed on file '/home/ale/play/alertme.so': Permission denied"
>
> > Permission? here are the file in question's permissions:
> > -rwxrwxrwx
>
> How about permissions on the directories in the path?
>
> regards, tom lane

--
Alejandro Fernandez
Electronic Group Interactive
--+34-65-232-8086--

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Holger Marzen 2002-05-03 08:41:51 Re: Subject: bool / vacuum full bug followup
Previous Message Vaclav Kulakovsky 2002-05-03 07:23:49 Re: Data integrity problem !!!