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: making a trigger to a system call to a shell script
Date: 2002-05-02 15:30:41
Message-ID: 20020502173041.2c71e687.ale@e-group.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have the short term problem of needing to know quite fast when someone updates or inserts a column in a table I have. It's something I hope to automate, but for now I've been looking around for a way to trigger a shell script to send me an email whenever this table is added to.

I looked around on archives of over a year ago on this and other psql lists, and it all seemed to point to creating a function in C that is then added as a trigger to postgres. It seems strange to me that this little feature is not there, but I don't mind coding in C, so I thought I'd give it a go.

I even found a great reference to this: Bruce Momjan's book, specifically, the little section on "extending postgresql in C".

I followed this, created a little function that takes a char and returns the usual int, then I downloaded all of the newest version of postgresql, in response to http://www.ca.postgresql.org/docs/aw_pgsql_book/node170.html - and finally issued some dubious compilation commands to make the dynamically linked c file (is this too much work for a seemingly simple task like this??), based on the headers I'd just downloaded :

gcc -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -fpic -I/opt/downloads/postgresql-7.2.1/src/interfaces/libpq -I /opt/downloads/postgresql-7.2.1/src/include/ -c -o alertme.o alertme.c

and now I've tried the following command as user postgres, in psql:

create function alertme(char) returns int as '/home/ale/c/alertme.so' language 'C';

and it says "stat failed on file '/home/ale/play/alertme.so': Permission denied"

Permission? here are the file in question's permissions:
-rwxrwxrwx

That's more than's even safe... What am I doing wrong??

Thanks,

Ale

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2002-05-02 15:34:19 Re: HOWTO - Random character generation for primary key
Previous Message Fran Fabrizio 2002-05-02 15:27:51 Re: Joe Celko Function