Re: NOTIFY in Background Worker - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: NOTIFY in Background Worker
Date
Msg-id CAEepm=2jP7RzLNVt2vAyV0XojF5PEJ64Ltb64hnW5GVHd=S0JA@mail.gmail.com
Whole thread Raw
In response to NOTIFY in Background Worker  (jacques klein <jacques.klei@googlemail.com>)
Responses Re: NOTIFY in Background Worker  (Thomas Munro <thomas.munro@enterprisedb.com>)
List pgsql-hackers
On Fri, Aug 28, 2015 at 10:30 PM, jacques klein <jacques.klei@googlemail.com> wrote:
Hello,

I added a "NOFITY chan" to the SQL arg of an SPI_execute(), (I did it also with just the NOTIFY statement),
but the listeners (other workers) don't get the notification until a "NOTIFY chan" is done for example with pgadmin,

They don't get lost, just not emited after the "not forgotten" call of CommitTransactionCommand().

Is this normal ( i.e. not supported (yet) ), a bug, or did I overlook some doc. (or source code) ?.

For now, I will try to "emit" the NOTIFY via libpq.

That's because ProcessCompletedNotifies isn't being called.  For regular backends it is called inside the top level loop PostgresMain.  I think you need to include "commands/async.h" and add a call to ProcessCompletedNotifies() after your background worker commits to make this work.

--

pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: proposal: multiple psql option -c
Next
From: Bruce Momjian
Date:
Subject: Adding commit details to SGML release notes