C vs plpgsql and child processes - Mailing list pgsql-general

From Jason Godden
Subject C vs plpgsql and child processes
Date
Msg-id 200308172328.33207.jasongodden@optushome.com.au
Whole thread Raw
Responses Re: C vs plpgsql and child processes
List pgsql-general
Hi All,

I've written a few C functions in the version 1 format as well as some SPI
based backend bits and I'm curious as to how PG treats these items when used
within plpgsql.

The set of functions control external processes.  One function is called with
various items governed by the db, does a fork and then execl to from the
child to start a new process.  Whilst it's not posix i ignore the SIGCHLD
signal and let the parent process return the pid to postgres.  This seems to
all be good and postgres itself obviously doesn't wait for the child to
finish (which is intentional).  When the child finishes it terminates
correctly and doesn't zombie out.

Problem is that when I call these particular functions from within plpgsql
rather than through a single sql command the child never actually starts (or
starts and then exits immediately).  I presume it's more to do with the fact
that what I'm doing is a bit of a hack in some senses and isn't really the
best way to go about it.  Is there any specific reason why this idea wouldn't
work within plpgsql?  Or should I look at moving the whole function to C?  I
can certainly appreciate why it wouldn't work - just some info as to the best
way to achieve this concept would be great.

Rgds,

Jason

pgsql-general by date:

Previous
From: stephane parenton
Date:
Subject: Re: insert and heritage... ooops... solved
Next
From: "Nikola Milutinovic"
Date:
Subject: Re: Dreamweaver