Re: Setting global vars for use with triggers

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Setting global vars for use with triggers
Дата
Msg-id 20050623000614.GA30804@winnie.fuhr.org
обсуждение исходный текст
Ответ на Setting global vars for use with triggers  (CSN <cool_screen_name90001@yahoo.com>)
Список pgsql-general
On Wed, Jun 22, 2005 at 01:36:20PM -0700, CSN wrote:
>
> I'd like to create a trigger which deletes associated
> files whenever their corresponding row is deleted.

I looked at the thread you posted and saw that you were considering
using LISTEN/NOTIFY.  That's probably a good idea because if you
delete a file in a trigger, you don't have a way to undelete it if
the transaction rolls back.  If you use NOTIFY then the notification
should be delivered to the listener only if the transaction commits.

Ideally the listener wouldn't repeatedly sleep and check for
notifications -- you'd use a function like select() or poll() in C
(socket_select() in PHP) that would tell you immediately when data
is available on the database connection's socket (and only then).
Unfortunately I don't see a way for the PHP PostgreSQL interface
to get the connection's file descriptor as you would in C with
PQsocket().  If you use PHP then you might be stuck with sleep/check,
so you might want to consider writing the listener in another
language.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: multiple action rules
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Vacuum advice