pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Can the frontend get notifications from the postgres server?
10+ messages / 5 participants
[nested] [flat]

* Can the frontend get notifications from the postgres server?
@ 2003-06-17 04:39  Anagha Joshi <ajoshi@nulinkinc.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Anagha Joshi @ 2003-06-17 04:39 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres server?
@ 2003-06-17 05:28  weigelt@metux.de
  parent: Anagha Joshi <ajoshi@nulinkinc.com>
  0 siblings, 1 reply; 10+ messages in thread

From: weigelt@metux.de @ 2003-06-17 05:28 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org

On Tue, Jun 17, 2003 at 10:09:04AM +0530, Anagha Joshi wrote:
> 
(qestion in subject ...)

yes.
simply execute LISTEN <eventname>; on the one side and then 
an NOTIFY <eventname> on the other side. on the next query 
you'll see the notify. (you can easily try it w/ pgsql)

but i currently dont know, if you can receive notifies in php ... 
that's what i'm really interested in ...

cu 
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux ITS 
 Webhosting ab 5 EUR/Monat.          UUCP, rawIP und vieles mehr.

 phone:     +49 36207 519931         www:       http://www.metux.de/     
 fax:       +49 36207 519932         email:     contact@metux.de
 cellphone: +49 174 7066481	     smsgate:   sms.weigelt@metux.de
---------------------------------------------------------------------
 Diese Mail wurde mit UUCP versandt.      http://www.metux.de/uucp/



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres
@ 2003-06-17 06:37  A.Bhuvaneswaran <bhuvan@symonds.net>
  parent: weigelt@metux.de
  0 siblings, 1 reply; 10+ messages in thread

From: A.Bhuvaneswaran @ 2003-06-17 06:37 UTC (permalink / raw)
  To: weigelt@metux.de; +Cc: pgsql-admin@postgresql.org

> yes.
> simply execute LISTEN <eventname>; on the one side and then 
> an NOTIFY <eventname> on the other side. on the next query 
> you'll see the notify. (you can easily try it w/ pgsql)
> 
> but i currently dont know, if you can receive notifies in php ... 
> that's what i'm really interested in ...

LISTEN/NOTIFY is yet another SQL. We can write a rule on an event and let 
it notify. On the other hand, we can have a while(1) process which keeps 
listening for that notification ie.. event. Once the event is occured, the 
listening process would be notified. The listening process can be any 
postgresql client including the one written in C, perl, php, etc.

regards,
bhuvaneswaran




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres server?
@ 2003-06-17 08:01  weigelt@metux.de
  parent: A.Bhuvaneswaran <bhuvan@symonds.net>
  0 siblings, 3 replies; 10+ messages in thread

From: weigelt@metux.de @ 2003-06-17 08:01 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org

On Tue, Jun 17, 2003 at 12:07:31PM +0530, A.Bhuvaneswaran wrote:

<snip>
> LISTEN/NOTIFY is yet another SQL. We can write a rule on an event and let 
> it notify. On the other hand, we can have a while(1) process which keeps 
> listening for that notification ie.. event. Once the event is occured, the 
> listening process would be notified. The listening process can be any 
> postgresql client including the one written in C, perl, php, etc.
But the problem still is: how to receive the NOTIFY from an php script ?
which function of the c-client lib can be used for this ?

cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux ITS 
 Webhosting ab 5 EUR/Monat.          UUCP, rawIP und vieles mehr.

 phone:     +49 36207 519931         www:       http://www.metux.de/     
 fax:       +49 36207 519932         email:     contact@metux.de
 cellphone: +49 174 7066481	     smsgate:   sms.weigelt@metux.de
---------------------------------------------------------------------
 Diese Mail wurde mit UUCP versandt.      http://www.metux.de/uucp/



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres
@ 2003-06-17 12:08  scott.marlowe <scott.marlowe@ihs.com>
  parent: weigelt@metux.de
  2 siblings, 1 reply; 10+ messages in thread

From: scott.marlowe @ 2003-06-17 12:08 UTC (permalink / raw)
  To: weigelt@metux.de; +Cc: pgsql-admin@postgresql.org

On Tue, 17 Jun 2003 weigelt@metux.de wrote:

> On Tue, Jun 17, 2003 at 12:07:31PM +0530, A.Bhuvaneswaran wrote:
> 
> <snip>
> > LISTEN/NOTIFY is yet another SQL. We can write a rule on an event and let 
> > it notify. On the other hand, we can have a while(1) process which keeps 
> > listening for that notification ie.. event. Once the event is occured, the 
> > listening process would be notified. The listening process can be any 
> > postgresql client including the one written in C, perl, php, etc.
> But the problem still is: how to receive the NOTIFY from an php script ?
> which function of the c-client lib can be used for this ?

If you're talking about a PHP script running under apache as a module or 
CGI, then you probably can't (or if you can, you shouldn't due to time out 
issues and such.)

Note that PHP really is a "real programming language", and if you write a 
program to execute from the command line and detach it can run in the back 
ground like any other language, even starting child processes and having 
IPC and all that.  Look up the "Process Control Functions" for more on 
satrting child processes and all.

Note that the pcntl_* functions are not guaranteed to behave when run 
under apache / as a CGI etc...




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres
@ 2003-06-17 12:27  A.Bhuvaneswaran <bhuvan@symonds.net>
  parent: weigelt@metux.de
  2 siblings, 1 reply; 10+ messages in thread

From: A.Bhuvaneswaran @ 2003-06-17 12:27 UTC (permalink / raw)
  To: weigelt@metux.de; +Cc: pgsql-admin@postgresql.org

> > LISTEN/NOTIFY is yet another SQL. We can write a rule on an event and let 
> > it notify. On the other hand, we can have a while(1) process which keeps 
> > listening for that notification ie.. event. Once the event is occured, the 
> > listening process would be notified. The listening process can be any 
> > postgresql client including the one written in C, perl, php, etc.
> But the problem still is: how to receive the NOTIFY from an php script ?
> which function of the c-client lib can be used for this ?

In perl, if i am correct, DBD::Pg does not support it. But, Pg - Perl5
extension for postgresql does it. The functions consumeInput() and
notifies can be used to access the notifyname and pid of backend process.
Refer the man page of Pg module for details.

In C, the functions PQconsumeInput() and PQnotifies can be used to access 
the notifyname and pid of backend process. Refer the libpq man page for 
details. 

In php 4.3.0, the function pg_get_notify() can be used to access the
notifyname and pid of backend process. For details, please refer the below
link:

http://www.science.uva.nl/ict/documentation/php4/function.pg-get-notify.html

Hope it helps.

regards,
bhuvaneswaran




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres server?
@ 2003-06-17 12:38  weigelt@metux.de
  parent: scott.marlowe <scott.marlowe@ihs.com>
  0 siblings, 0 replies; 10+ messages in thread

From: weigelt@metux.de @ 2003-06-17 12:38 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org

On Tue, Jun 17, 2003 at 06:08:43AM -0600, scott.marlowe wrote:

<snip>
> > But the problem still is: how to receive the NOTIFY from an php script ?
> > which function of the c-client lib can be used for this ?
> 
> If you're talking about a PHP script running under apache as a module or 
> CGI, then you probably can't (or if you can, you shouldn't due to time out 
> issues and such.)
No. The script is running as an standalone process (works as application server).
The Problem is, how to get the NOTIFY message, which is received from the
RDBMS somewhere in the client lib, to the php script.
When using psql, the NOTIFY is displayed after sending an query. It seems
that it is sent within the server's reply to the query. But i dont know
how the clientlib hands it to the application.

cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux ITS 
 Webhosting ab 5 EUR/Monat.          UUCP, rawIP und vieles mehr.

 phone:     +49 36207 519931         www:       http://www.metux.de/     
 fax:       +49 36207 519932         email:     contact@metux.de
 cellphone: +49 174 7066481	     smsgate:   sms.weigelt@metux.de
---------------------------------------------------------------------
 Diese Mail wurde mit UUCP versandt.      http://www.metux.de/uucp/



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres server?
@ 2003-06-17 12:40  weigelt@metux.de
  parent: A.Bhuvaneswaran <bhuvan@symonds.net>
  0 siblings, 0 replies; 10+ messages in thread

From: weigelt@metux.de @ 2003-06-17 12:40 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org

On Tue, Jun 17, 2003 at 05:57:32PM +0530, A.Bhuvaneswaran wrote:

<snip>
> In php 4.3.0, the function pg_get_notify() can be used to access the
> notifyname and pid of backend process. For details, please refer the below
> link:
aaah. that's what i needed :)

cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux ITS 
 Webhosting ab 5 EUR/Monat.          UUCP, rawIP und vieles mehr.

 phone:     +49 36207 519931         www:       http://www.metux.de/     
 fax:       +49 36207 519932         email:     contact@metux.de
 cellphone: +49 174 7066481	     smsgate:   sms.weigelt@metux.de
---------------------------------------------------------------------
 Diese Mail wurde mit UUCP versandt.      http://www.metux.de/uucp/



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Can the frontend get notifications from the postgres server?
@ 2003-06-17 20:37  Jonathan Gardner <jgardner@jonathangardner.net>
  parent: weigelt@metux.de
  2 siblings, 1 reply; 10+ messages in thread

From: Jonathan Gardner @ 2003-06-17 20:37 UTC (permalink / raw)
  To: weigelt@metux.de; pgsql-admin@postgresql.org

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 17 June 2003 01:01, weigelt@metux.de wrote:
> On Tue, Jun 17, 2003 at 12:07:31PM +0530, A.Bhuvaneswaran wrote:
>
> But the problem still is: how to receive the NOTIFY from an php script ?
> which function of the c-client lib can be used for this ?
>

Why in the world would you want to? Think about this for a moment: The script 
runs in under a second - why would it want to sit around and wait for a 
notification?

- -- 
Jonathan Gardner <jgardner@jonathangardner.net>
(was jgardn@alumni.washington.edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+73wRWgwF3QvpWNwRAistAJ4osnbDTKNQfg/0e83yR4SGq2eWSQCgy5iQ
8jx/eb09AFe4Kiy9WDhJa+k=
=vilQ
-----END PGP SIGNATURE-----



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [ADMIN] Can the frontend get notifications from the postgres server?
@ 2003-06-17 23:34  weigelt@metux.de
  parent: Jonathan Gardner <jgardner@jonathangardner.net>
  0 siblings, 0 replies; 10+ messages in thread

From: weigelt@metux.de @ 2003-06-17 23:34 UTC (permalink / raw)
  To: pgsql-sql

On Tue, Jun 17, 2003 at 01:37:37PM -0700, Jonathan Gardner wrote:

<snip>
> Why in the world would you want to? Think about this for a moment: 
> The script runs in under a second - why would it want to sit around 
> and wait for a notification?
No, my script runs hours, days, month ...

cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux ITS 
 Webhosting ab 5 EUR/Monat.          UUCP, rawIP und vieles mehr.

 phone:     +49 36207 519931         www:       http://www.metux.de/     
 fax:       +49 36207 519932         email:     contact@metux.de
 cellphone: +49 174 7066481	     smsgate:   sms.weigelt@metux.de
---------------------------------------------------------------------
 Diese Mail wurde mit UUCP versandt.      http://www.metux.de/uucp/



^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2003-06-17 23:34 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-17 04:39 Can the frontend get notifications from the postgres server? Anagha Joshi <ajoshi@nulinkinc.com>
2003-06-17 05:28 ` weigelt@metux.de
2003-06-17 06:37   ` Re: Can the frontend get notifications from the postgres A.Bhuvaneswaran <bhuvan@symonds.net>
2003-06-17 08:01     ` weigelt@metux.de
2003-06-17 12:08       ` Re: Can the frontend get notifications from the postgres scott.marlowe <scott.marlowe@ihs.com>
2003-06-17 12:38         ` weigelt@metux.de
2003-06-17 12:27       ` Re: Can the frontend get notifications from the postgres A.Bhuvaneswaran <bhuvan@symonds.net>
2003-06-17 12:40         ` weigelt@metux.de
2003-06-17 20:37       ` Jonathan Gardner <jgardner@jonathangardner.net>
2003-06-17 23:34         ` weigelt@metux.de

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox