X-Original-To: pgsql-interfaces@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3A9FA474E4F for ; Tue, 25 Feb 2003 15:26:08 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 79519-01 for ; Tue, 25 Feb 2003 15:25:40 -0500 (EST) Received: from crtntx1-ar11-4-62-011-208.crtntx1.dsl-verizon.net (crtntx1-ar11-4-62-009-178.crtntx1.dsl-verizon.net [4.62.9.178]) by postgresql.org (Postfix) with ESMTP id 062B84759BD for ; Tue, 25 Feb 2003 15:23:33 -0500 (EST) Received: from reliant.home.pri (reliant.home.pri [192.168.1.25]) by crtntx1-ar11-4-62-011-208.crtntx1.dsl-verizon.net (Postfix) with ESMTP id 4AFCD3018 for ; Tue, 25 Feb 2003 14:23:48 -0600 (CST) Subject: Re: Using LISTEN/NOTIFY with ecpg From: Matthew Vanecek To: Postgresql Interfaces List In-Reply-To: <3E5A2B67.23B3A128@rodos.fzk.de> References: <3E5A2B67.23B3A128@rodos.fzk.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-22FCv+SqpOJ0DOJoz8gf" Organization: Message-Id: <1046204614.12260.60.camel@reliant.home.pri> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 25 Feb 2003 14:23:34 -0600 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/104 X-Sequence-Number: 3725 --=-22FCv+SqpOJ0DOJoz8gf Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2003-02-24 at 08:25, Christoph Haller wrote: > > > > Does anyone have any examples of using LISTEN/NOTIFY with ecpg? Is > that > > a supported functionality? If not, is there a way to work around it? > > > No, I have no example and I don't know if it's supported at all. > But the libpq interface offers Asynchronous Notification > via the LISTEN and NOTIFY commands. See there. > And it's no problem at all to use libpq functions from within embedded > SQL > programs. You have to link with -lpq anyway, so I'm pretty positive just > using > PQnotifies should work. Furthermore, there is an example program at > Example 1-2. libpq Example Program 2 > Test of the asynchronous notification interface >=20 Thanks, it looks like that's what I'm going to have to do. However, running "EXEC SQL NOTIFY listener" doesn't appear to work. If I run the above from one connection, and on another connection run PQnotifies(conn);, the notification is not received. Using PQexec(conn, "NOTIFY listener") *does* work. That means for every update/insert/delete accomplished by ECPG, I also need a PGconn object with which to send a NOTIFY, and to LISTEN for NOTIFYs after executing queries. That's a somewhat undesirable situation, of course. I don't know what ECPG is doing with the EXEC SQL NOTIFY listener;. It doesn't appear to be setting it on the connection object ECPG uses.=20 EXEC SQL LISTEN listener; *does* work, but the results are only piped to ECPGlog and are not available for application consumption. So in one application, I can do: EXEC SQL LISTEN listener; And in another instance I can do: result =3D PQexec(conn, "NOTIFY listener"); and ECPGlog outputs something like: [25423]: ECPGexecute line 90: ASYNC NOTIFY of 'gnucash' from backend pid '26191' received If I do either: EXEC SQL LISTEN listener; or result =3D PQexec(conn, "LISTEN listener"); note =3D PQnotifies(conn); and then do in another instance: EXEC SQL NOTIFY listener; the first instance never receives the notification. ECPG doesn't log the ASYNC notification, and PQnotifies() returns NULL. The fact of LISTEN not being consumable by an ECPG application sounds like an RFE, to me, since in some cases the notification is already going to ECPGlog(). The fact that NOTIFY apparently accomplishes nothing in ECPG seems to me like a bug. If I EXEC SQL NOTIFY listener; on a db, then a listening libpq application ought to be able to receive that NOTIFY event. So, there we are. I don't know exactly what to do about the latter situation. I don't really have time to track it down at this particular time--I need to get some work done on my own application. If someone provides a patch, though, I'd be happy to test it... --=20 Matthew Vanecek perl -e 'print $i=3Dpack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);' ***************************************************************************= ***** For 93 million miles, there is nothing between the sun and my shadow except= me. I'm always getting in the way of something... --=-22FCv+SqpOJ0DOJoz8gf Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQA+W9DGi/CNzDSN0RIRAvK6AJ9bmKFEXlFrz9VDswyYpNO4J0wqqwCdHN/k uKmqcWkEOaZK7J99MPLuVTs= =6cjb -----END PGP SIGNATURE----- --=-22FCv+SqpOJ0DOJoz8gf--