NOTIFY tableX, LISTEN tableX, pool Nofities()

From: Davi Leal <davileal(at)terra(dot)es>
To: pgsql-general(at)postgresql(dot)org
Cc: shopsuite-dev(at)mail(dot)freesoftware(dot)fsf(dot)org
Subject: NOTIFY tableX, LISTEN tableX, pool Nofities()
Date: 2002-03-28 18:24:57
Message-ID: 200203281727.g2SHR1tb019240@excalibur.ene.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am developing an n-tier application which uses postgresql 7.2. It has several windows to show Data Base data. If the DB modifies its data then some or each window must update the showed information. To realize it the DB send "NOTIFY <table X changed>".

The problem is that if a window catch a "NOTIFY table1", another window of the same process, which must update too the table1's information, does not update due to the asynchronous notification to this backend has already been processed.

Must I use a thread to each application's window?.

Must I do a central collect of notifies and raise the update of windows from there?. Yes, I think so. :-) However, I need to know the exact type of notify which the backend gets: "NOTIFY table1", "NOTIFY table2", or ...

How could I differentiate from several types of "NOTIFY tableX" ?.

Which are the fields of the PGnotify* PgDatabase::Notifies() ?.

Note: You can see attached examples as C or C++ code which catch the NOTIFY from the data base doing a pool. To compile it on Debian GNU/Linux (sid) you can do:
gcc -o testlibpq2-C testlibpq2.c -I /usr/include/postgresql/ -lpq
g++ -o testlibpq2-C++ testlibpq2.cpp -I /usr/include/postgresql/ -lpq++

Regards,
Davi Leal

Attachment Content-Type Size
testlibpq2.c text/x-c 2.9 KB
testlibpq2.cpp text/x-c++ 1.9 KB

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Luc Lachance 2002-03-28 18:34:43 How to abort a pgaccess query?
Previous Message Jean-Luc Lachance 2002-03-28 18:21:05 Re: Sum