Re: A simple extension immitating pg_notify - Mailing list pgsql-general

From Tom Lane
Subject Re: A simple extension immitating pg_notify
Date
Msg-id 4589.1469373218@sss.pgh.pa.us
Whole thread Raw
In response to Re: A simple extension immitating pg_notify  (Mehran Ziadloo <mehran20@hotmail.com>)
List pgsql-general
Mehran Ziadloo <mehran20@hotmail.com> writes:
> What I meant was that the notifications are received by the client connectionsas if it was generated within their
correspondingdatabase (let's name thedatabase with a client connection listening to it; DB_C), then a notification
generatedby a NOTIFY command within DB_X like this: 
> pg_notify_db('DB_C', some_channel, 'payload');
> can be heard by the client. Of course, the client needs to know which databasehas sent the notification but I think
wecan skip that part since we can easilyinclude database name in the notification's payload if necessary. 
> That was one of the two solutions. The other one is like this:
> pg_notify_all(some_channel, 'payload');
> And this one sends the notification to all of the client connections,regardless of which database they are
connected/listeningto. 

I do not think the first one would be too hard (look in commands/async.c),
but the second one would be problematic, because of the assumption that
NOTIFY message contents are expressed in the relevant database's encoding.
In the first case you could put it on the head of the sending backend to
convert to the target DB's encoding --- and, if that conversion failed,
it could error out cleanly: no message sent, no transaction committed.
In the second case you would have to make it the responsibility of
receiving backends to do the encoding conversions, and AFAICS it'd be
impossible to have clean semantics for failures: the sending transaction
would have committed all right, but some of the recipients wouldn't get
the notification.

            regards, tom lane


pgsql-general by date:

Previous
From: Sylvain Marechal
Date:
Subject: Re: A simple extension immitating pg_notify
Next
From: Tom Lane
Date:
Subject: Re: A simple extension immitating pg_notify