From: | Alessandro GARDICH <gremlin(at)gremlin(dot)it> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | notify problem |
Date: | 2003-09-05 07:21:07 |
Message-ID: | 1062746373.2225.40.camel@motoko.loc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi to all
I have problem with NOTIFY/LISTEN ...
I'm writing a C++ application with libpqxx, I thought was a problem of
the lib but I try also with a C program using libpq with the same
result, so maybe there is something else of wrong.
Using the example 2 in the libpq chapter on "Postgres Programmer's
Guide" as template i write :
!---------->
#include <unistd.h>
#include <libpq-fe.h>
int main() {
PGconn *conn;
PGresult *res;
PGnotify *notify;
int i;
conn = PQconnectdb ("host=localhost user=test dbname=test");
if (PQstatus(conn) == CONNECTION_BAD) {
fprintf(stderr,"failed connecting.\n");
PQfinish(conn);
exit(1);
}
res = PQexec(conn, "LISTEN alert");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
fprintf(stderr,"failed listening.\n");
PQclear(res);
PQfinish(conn);
exit(1);
}
PQclear(res);
for(i = 0; i < 80 ; ++i) {
sleep(1);
PQconsumeInput(conn);
while ((notify = PQnotifies(conn)) != NULL) {
fprintf(stderr,"\nGOT NOTIFY!!!\n");
free(notify);
}
fprintf(stderr,".");
}
PQfinish(conn);
return 0;
}
<----------!
On a console with psql I issue some notify with
NOTIFY alert; COMMIT;
but nothing are catched !!!
if in another console with psql i do a "LISTEN alert;" all work
correctly.
I'm using Linux, RedHat 9, so PostgreSQL 7.3.2.
user and database are created with :
createuser -h localhost -U postgres -D -A -P test
createdb -O test -h localhost -U postgres test
and nothing alse, the database are empty.
what's wrong ???
Thanks.
--
Alessandro GARDICH <gremlin(at)gremlin(dot)it>
gremlin.it
From | Date | Subject | |
---|---|---|---|
Next Message | Csaba Nagy | 2003-09-05 08:44:04 | Re: Replaceing records |
Previous Message | Bjorn T Johansen | 2003-09-05 06:57:55 | Re: Seq scan of table? |