Re: waiting for notfications on the server

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Marc Munro <marc(at)bloodnok(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: waiting for notfications on the server
Date: 2011-06-10 19:45:54
Message-ID: BANLkTi=6qQVkVRpngUULO=cGa25Nhs3yDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jun 10, 2011 at 2:10 PM, Marc Munro <marc(at)bloodnok(dot)com> wrote:
> I'd like to be able to wait for notify events using a user-defined C
> function.  All of the examples and code I can find use libpq.
>
> Is there some way I can synchronously wait for notify events using SPI?
>
> Is there some reason this is a dumb idea?  I wondered about the risk of
> deadlocking a backend but can't see why using libpq would eliminate this
> risk.

Unfortunately, this is not a good idea.

The problem is that SPI functions are in a single transaction for the
duration of their lifetime. You have to do it in the client -- a
hypothetical future 'stored procedure' implementation may be able to
do this -- see extensive, albeit inconclusive, fairly recent
discussion on -hackers.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message akp geek 2011-06-10 19:46:52 setting up streaming error. Please help
Previous Message Marc Munro 2011-06-10 19:10:26 waiting for notfications on the server