Re: Run a unix or perl command in a trigger
От | Mike Nolan |
---|---|
Тема | Re: Run a unix or perl command in a trigger |
Дата | |
Msg-id | 200407031333.i63DXlHW015538@gw.tssi.com обсуждение исходный текст |
Ответ на | Run a unix or perl command in a trigger (Thierry Missimilly <THIERRY.MISSIMILLY@bull.net>) |
Список | pgsql-general |
> I wonder to know if it is possible to launch a Perl program or a unix > comand in a trigger function. > I have tried to do that in a C trigger developed with the SPI function. > But my examples does not work and i don't have any error messages in the > postgres logfile. > So, i ask you your opinion and an example of code if your trigger works. I guess I'm not sure what you mean by 'launch'. Do you need to query the results? Here's a plperlu function that runs an external shell script. I've not tried it in a trigger, but it should work. This function needs to be created as a superuser since it uses 'untrusted' perl. It creates a security hole in that anyone who has write access to the postgres user home directory can run ANYTHING. -- Mike Nolan create or replace function submit_batch(varchar, varchar) returns varchar security invoker as ' # perl body goes here # parameters: user ID # batch id $command = "/home/postgres/submit_batch.job " . "$_[0]" . " " . "$_[1]" ; $x = system($command); return $x; ' language plperlu;
В списке pgsql-general по дате отправления: