Unlisten / listen in a transaction failure

From: Greg Sabino Mullane <greg(at)endpoint(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Unlisten / listen in a transaction failure
Date: 2013-02-13 14:55:22
Message-ID: 20130213145522.GI23404@broken.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I came across some unusual behavior with listen. Basically, if you
unlisten and listen inside of a transaction, new notices are not
picked up right away - but they will show up if you send yourself
a notice. It also works as expected if you unlisten, commit, and
then re-listen. Tested on 9.1 and 9.2. Demo psql script:

listen abc; \t
\! psql -p 5491 -c 'notify abc'
select * from pg_listening_channels();

begin; unlisten *; listen abc; commit;
\! psql -p 5491 -c 'notify abc'
select * from pg_listening_channels();

notify abc;

Output of above on 9.1 with psql -e:

listen abc;
LISTEN
Showing only tuples.
NOTIFY
select * from pg_listening_channels();
abc

Asynchronous notification "abc" received from server process with PID 10879.

begin;
BEGIN
unlisten *;
UNLISTEN
listen abc;
LISTEN
commit;
COMMIT
NOTIFY
select * from pg_listening_channels();
abc

notify abc;
NOTIFY
Asynchronous notification "abc" received from server process with PID 10882.
Asynchronous notification "abc" received from server process with PID 10876.

--
Greg Sabino Mullane greg(at)endpoint(dot)com
End Point Corporation
PGP Key: 0x14964AC8

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-02-13 16:16:59 Re: Unlisten / listen in a transaction failure
Previous Message bernardjech 2013-02-12 16:39:42 BUG #7869: Expressions in a view for rows that are not part of the view result set are still evaluated