Re: notification: pg_notify ?

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: notification: pg_notify ?
Date: 2002-03-22 13:11:25
Message-ID: 1016802690.9193.16.camel@taru.tm.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2002-03-22 at 06:40, Tom Lane wrote:
> Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> >> BTW, I would like to see a spec for this "notify with parameter" feature
> >> before it's implemented, not after.
>
> > The current syntax I'm using is:
> > NOTIFY condition_name [ [WITH MESSAGE] 'my message' ];
>
> Hm. How are you going to transmit that to the client side without
> changing the FE/BE protocol? (While we will no doubt find reasons
> to change the protocol in the future, I'm not eager to force a protocol
> update right now; at least not without more reason than just NOTIFY
> parameters.) If we want to avoid a protocol break then it seems
> like the value transmitted to the client has to be a single string.
>
> I guess we could say that what's transmitted is a single string in
> the form
> condition_name.additional_text
> (or pick some other delimiter instead of dot, but doesn't seem like
> it matters much). Pretty grotty though.
>
> Another thought that comes to mind is that we could reinterpret the
> parameter of LISTEN as a pattern to match against the strings generated
> by NOTIFY --- then there's no need to draw a hard-and-fast distinction
> between condition name and parameter text; it's all in the eye of the
> beholder.

That'ts what I suggested a few weeks ago in a well hidden message at the
end of reply to somewhat related question ;)

> However it's tough to see how to do this without breaking
> backwards compatibility at the syntax level --- you'd really want LISTEN
> to be accepting a string literal, rather than a name, to make this
> happen.

Can't we accept both - name for simple things and string for regexes.

> That brings up the more general point that you'd want at least
> the "message" part of NOTIFY to be computable as an SQL expression,
> not just a literal.

I think this should be any expression that returns text.

I even wouldnt mind if I had to use explicit insert:

insert into pg_notify
select
relname || '.' || cast(myobjectid as text),
listenerpid
from pg_listener
where 'inv' ~ relname

Just the delivery has to be automatic.

> It might be entertaining to try to reimplement
> NOTIFY as something that's internally like a SELECT, just with a
> funny data destination.

I thought that NOTIFY is implemented as an INSERT internally, no ?

> I find this attractive because if it were
> a SELECT then it could have (at least on the inside) a WHERE clause,
> which'd make it possible to handle NOTIFYs in conditional rules in
> a less broken fashion than we do now.

--------------
Hannu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas SB SD 2002-03-22 14:42:16 Re: SET NULL / SET NOT NULL
Previous Message D'Arcy J.M. Cain 2002-03-22 12:51:02 Re: SET NULL / SET NOT NULL