From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Cory Tucker <cory(dot)tucker(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Determine all listeners subscribed to notifcations and what channels |
Date: | 2015-02-17 23:02:20 |
Message-ID: | CAHyXU0yyFO06T7+A5Ha-=9=skfqh_5ZPx-vhSPn1Ow-B28NYAA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Feb 17, 2015 at 4:01 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Cory Tucker <cory(dot)tucker(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Melvin Davidson | 2015-02-17 23:14:39 | Re: Issue dumping schema using readonly user |
Previous Message | Saimon | 2015-02-17 22:53:50 | Revoking access for pg_catalog schema objects |