Re: Trigger that spawns forked process

From: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
To: Christopher Murtagh <christopher(dot)murtagh(at)mcgill(dot)ca>
Cc: Douglas McNaught <doug(at)mcnaught(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trigger that spawns forked process
Date: 2005-05-10 16:11:22
Message-ID: 20050510161121.GC31103@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 09, 2005 at 09:07:40PM -0400, Christopher Murtagh wrote:
> On Mon, 2005-05-09 at 17:01 -0400, Douglas McNaught wrote:
> > Why not have a client connection LISTENing and doing the
> > synchronization, and have the trigger use NOTIFY?
> >
> > Or, you could have the trigger write to a table, and have another
> > client periodically scanning the table for new sync events.
> >
> > Either one of those would be simpler and more robust than fork()ing
> > inside the backend.
>
> How is writing a daemon simpler than using something that could be done
> within Postgres? Forking is something that should be natural to Unix
> systems, I shouldn't need to write another application to do this. I
> don't see how a daemon would necessarily be more robust either.

Well, LISTEN and NOTIFY are built into PostgreSQL
(http://www.postgresql.org/docs/8.0/interactive/sql-notify.html). If the
processes that you're trying to notify of the changes are connected to
the database then this might be the easiest way to do what you're
looking for. Setting up some form of replication, such as Slony, also
comes to mind. But it's impossible to really make a recommendation
without having a better idea of what you're doing.

BTW, my understanding is that it's pretty easy to write a daemon in
perl, and there are examples of how to do this floating around.
--
Jim C. Nasby, Database Consultant decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2005-05-10 16:29:58 Re: Loading a list of SQL scripts with relative paths
Previous Message Tom Lane 2005-05-10 15:49:50 Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL