From: | CSN <cool_screen_name90001(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | NOTIFY/LISTEN, PHP, rule vs. trigger, blocking, missed NOTIFY's |
Date: | 2005-08-10 00:52:52 |
Message-ID: | 20050810005252.71988.qmail@web52906.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Scott and I were discussing NOTIFY/LISTEN using a PHP
script here:
http://phpbuilder.com/board/showthread.php?t=10302693
Basically:
PHP Code:
#!/usr/bin/php -q
<?php
$conn = pg_connect("dbname=test user=user");
pg_query("listen record_deleted");
$interval = 10;
for (;1;){
sleep($interval);
$notify = pg_get_notify($conn);
if ($notify){
print "Now we do something";
}
}
?>
And the sql code:
CREATE TABLE ntest ( id serial primary key, path text
);
create table naudit ( id int primary key, path text );
create rule audit_test as on delete to ntest do (
insert into naudit(id,path) values (OLD.id, OLD.path);
notify record_deleted );
insert into ntest (path) values
('/usr/local/lib/php.ini2');
delete from ntest;
I think he may be off on some wild and exotic vacation
;) or something - so I'll post my questions here too:
* Is there any reason to use a rule rather than a
trigger? I guess a rule is just simpler.
* Also, think there's any way to just have the PHP
script block until a notify event is actually
received, rather than checking every [sleep] seconds?
* Finally, PG's docs on notify say that if events
happen in rapid succession, notify's might get
dropped. For example: could many item rows get
deleted, but some of their corresponding files not get
deleted due to dropped notify's?
Thanks,
CSN
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Randal L. Schwartz | 2005-08-10 01:35:46 | Re: Poll on your LAPP Preferences |
Previous Message | SCassidy | 2005-08-09 21:32:40 | Re: Suppressing Error messages. |