Re: Trigger that spawns forked process - Mailing list pgsql-general

From Tom Lane
Subject Re: Trigger that spawns forked process
Date
Msg-id 13860.1115837096@sss.pgh.pa.us
Whole thread Raw
In response to Re: Trigger that spawns forked process  (Christopher Murtagh <christopher.murtagh@mcgill.ca>)
List pgsql-general
Christopher Murtagh <christopher.murtagh@mcgill.ca> writes:
> So, if I made a slight modification to my script to this instead:

> CREATE or REPLACE function exec_test() returns void as '
> unless (defined ($pid=fork)) {
>      die "cannot fork: $!";
> }
> unless ($pid) {
>      $cmd="/path/to/some/script.pl";
>      exec "$cmd";
> }
> RETURN;
> ' language plperlu;

>  Is this less objectionable?

Well, it's better, but you need to think about what happens if the exec
fails (eg, script is not where you thought).  Does plperl let you get at
abort(), or some other way of terminating the process other than exit()?

There still remains the point that this violates transaction semantics,
in that an aborted transaction may still have caused things to happen
outside the database.

            regards, tom lane

pgsql-general by date:

Previous
From: Ruben Oliveira
Date:
Subject: Re: UPDATE Inserts New Rows
Next
From: Douglas McNaught
Date:
Subject: Re: Storing database in WORM devices