Re: Determine all listeners subscribed to notifcations and what channels

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Determine all listeners subscribed to notifcations and what channels
Дата
Msg-id CAHyXU0yyFO06T7+A5Ha-=9=skfqh_5ZPx-vhSPn1Ow-B28NYAA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Determine all listeners subscribed to notifcations and what channels  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Tue, Feb 17, 2015 at 4:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Cory Tucker <cory.tucker@gmail.com> 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Saimon
Дата:
Сообщение: Revoking access for pg_catalog schema objects
Следующее
От: Melvin Davidson
Дата:
Сообщение: Re: Issue dumping schema using readonly user