Search Postgresql Archives

Re: Determine all listeners subscribed to notifcations and what channels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 17, 2015 at 4:01 PM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
> Cory Tucker <cory.tucker@xxxxxxxxx> writes:
>> I'm interested in trying to figure out which channels have been subscribed
>> to (using LISTEN).  From what I could tell via a little Googling, there
>> used to be a table named pg_catalog.pg_listener that contained all this
>> information, but that seems to have disappeared somewhere in the 9.x
>> release (I'm using 9.3.x).
>
>> Is there a way to find out which channels have listeners?
>
> No, not any more --- that capability was intentionally given up in the
> 9.0 LISTEN/NOTIFY rewrite.  Not that it wouldn't be nice to have, but
> the cost/benefit ratio was pretty awful.

A userland wrapper could probably approximate this:
*) create a global id for each channel you want to listen on
(basically a table with channel names and a sequence)
*) create a function that looks up the id by channel and sharelocks
the id with an advisory lock, then listens on it
*) the advisory locks will clean themselves up when session ends
*) you can scan pg_locks table for type=advisory lock, pid, and the
ids of interest to get the data you want

merlin


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux