C vs plpgsql and child processes

From: Jason Godden <jasongodden(at)optushome(dot)com(dot)au>
To: pgsql-general(at)postgresql(dot)org
Subject: C vs plpgsql and child processes
Date: 2003-08-17 13:28:33
Message-ID: 200308172328.33207.jasongodden@optushome.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2003-08-17 15:06:19 Re: [PERFORM] PostgreSQL vs. MySQL
Previous Message stephane parenton 2003-08-17 12:58:40 Re: insert and heritage... ooops... solved