Обсуждение: LISTEN & NOTIFY data

Поиск
Список
Период
Сортировка

LISTEN & NOTIFY data

От
Burra
Дата:
Hello all,
Is there any way to send data along with the NOTIFY command... like
possibly oid?

I have a process listening on a certain NOTIFY name. When it gets that
signal from the database I want it to beable to get the "row" that was
affected and do some operations on it. Right now I have to do a
complex query to see what has changed... and that is just not efficent
enough for my needs. It would be great if postgres would get this
functionality, if it doesn't have it already... I hope :)

---------------------[-- burra@colorado.edu --]--------------------------


Re: LISTEN & NOTIFY data

От
Tom Lane
Дата:
Burra <burra@colorado.edu> writes:
> Is there any way to send data along with the NOTIFY command... like
> possibly oid?

Put the data you need into a table, and use NOTIFY as a signal that
it's time to look into that table.  Anything else can't work because
of the signal-ish nature of NOTIFY --- in particular, that if the same
condition is signaled multiple times while you are within a transaction
block, you'll get just one notification when you come out of the
transaction.  If you tried to piggyback OIDs on the messages, you'd lose
all but one.

You may care to study the advice given on the NOTIFY reference page.

            regards, tom lane

Re: LISTEN & NOTIFY data

От
Burra
Дата:
Is there any way to listen to all NOTIFY signals?

--------------------[-- burra@colorado.edu --]--------------------------

On Mon, 3 Dec 2001, Tom Lane wrote:

> Burra <burra@colorado.edu> writes:
> > Is there any way to send data along with the NOTIFY command... like
> > possibly oid?
>
> Put the data you need into a table, and use NOTIFY as a signal that
> it's time to look into that table.  Anything else can't work because
> of the signal-ish nature of NOTIFY --- in particular, that if the same
> condition is signaled multiple times while you are within a transaction
> block, you'll get just one notification when you come out of the
> transaction.  If you tried to piggyback OIDs on the messages, you'd lose
> all but one.
>
> You may care to study the advice given on the NOTIFY reference page.
>
>             regards, tom lane


Re: LISTEN & NOTIFY data

От
Tom Lane
Дата:
Burra <burra@colorado.edu> writes:
> Is there any way to listen to all NOTIFY signals?

Nope, you have to LISTEN to each name you want to hear about.

            regards, tom lane