X-Original-To: pgsql-interfaces@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 105534758FE for ; Tue, 25 Mar 2003 04:18:15 -0500 (EST) Received: from mailserv.mobilecohesion.com (picard.mobilecohesion.com [80.4.157.11]) by postgresql.org (Postfix) with ESMTP id C7FB2474E44 for ; Tue, 25 Mar 2003 04:18:13 -0500 (EST) Received: from [10.12.11.4] (helo=pestilence) by mailserv.mobilecohesion.com with asmtp (Exim 4.10) id 18xkZW-0005f4-00; Tue, 25 Mar 2003 09:18:18 +0000 Content-Type: text/plain; charset="iso-8859-2" From: Damien Dougan Organization: Mobile Cohesion To: Darko Prenosil , pgsql-interfaces@postgresql.org Subject: Re: Asynchronous Communication across two independent components Date: Tue, 25 Mar 2003 09:15:48 +0000 User-Agent: KMail/1.4.1 References: <200303241535.25156.damien.dougan@mobilecohesion.com> <200303242127.01355.darko.prenosil@finteh.hr> In-Reply-To: <200303242127.01355.darko.prenosil@finteh.hr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303250915.48917.damien.dougan@mobilecohesion.com> X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/142 X-Sequence-Number: 3891 Darko, Thanks for the response, but I'm not sure if your suggestions will meet my= =20 needs - as the page you referenced seems to suggest that these operations= =20 must all go over the same connection (and I have a Sender and a Receiver on= =20 separate connections). Some comments embedded below ... On Monday 24 March 2003 9:27 pm, you wrote: > You can send whole bunch of SQL commands using PQsendQuery, not only one ! > After that you can get more than one PGResults depending on what commands > you send to Postgres. You only need to terminate it with ";". > For example: > PQSendQuery("SELECT * FROM pg_table; BEGIN TRANSACTION; DELETE FROM tbl > WHERE id =3D 1; COMMIT;"); > When PQSendQuery command is executed, queries are just send to server. > Non-blocking means: program will not block and wait for results to come != !! > After that you should use combination of PQconsumeInput, PQisBusy and > PQgetResult. You can even cancel rest of the queries with PQrequestCancel. > It is all explained at: > http://developer.postgresql.org/docs/postgres/libpq-async.html , and it > works perfectly (spiking from my experience) !!! I did have a read through this before posting - and I was hoping the above= =20 mechanisms would do the trick for me - but there appears to be two problems= =20 with the PQsendQuery and PQgetResult. (1) You cannot call PQsendQuery on the same connection until PQgetResult ha= s=20 returned null. (2) You cannot call PQgetResult on a different connection from PQsendQuery = to=20 obtain the results of a query. So whilst your solution would be fine for asynchronous comms within a singl= e=20 connection, I'm afraid its not what I'm looking for! > If You need to wait to see if first command passes, and then send another, > threads and non-blocking commands can't help You! Then You simple must > execute with PQExec and wait for result ! > > > I also looked at the LISTEN/NOTIFY, which seemed promising. However, > > there does not appear to be any mechanism to identify the event that > > caused the notification. I was hoping to be able to have the Receiver > > handle the notification by going to the appropriate relation and picking > > up the data which was now ready for it - but there's no way to know whi= ch > > entry it is! > > You can RAISE NOTICE inside of the function("stored procedure") with > custom text. But You do not need this. PQsendQuery with multiple sql > commands is what you need ! > Thanks for the RAISE NOTICE heads-up - I'll take a look at this. Damien