PostgreSQL的notify 与listen (二)

磨砺技术珠矶,践行数据之道,追求卓越价值 

回到上一级页面: PostgreSQL基础知识与基本操作索引页     回到顶级页面:PostgreSQL索引页

 

接上文:PostgreSQL的notify 与listen (一)

PostgreSQL的notify 与 listen, 有如下的描述信息:

http://www.postgresql.org/docs/9.0/static/sql-notify.html

......

Secondly, if a listening session receives a notification signal while it is within a transaction, the notification event will not be delivered to its connected client until just after the transaction is completed (either committed or aborted).

......

就是说,listen 动作接受信息只能在 事务 和 事务之间。

验证如下:

一 Session A

postgres#listen event01;
postgres#begin;

postgres#select pg_sleep(100);
postgres#

二 Session B

postgres#notify event01;

三 然后回到 Session A
postgres#select pg_sleep(10);
postgres#
没有反应

四 再执行:
postgres#commit;
COMMIT

收到 来自伺服器 "event01"  进程PID 5558 非同步通知

回到上文:PostgreSQL的notify 与listen (一)

回到上一级页面: PostgreSQL基础知识与基本操作索引页     回到顶级页面:PostgreSQL索引页

磨砺技术珠矶,践行数据之道,追求卓越价值

posted @ 2012-07-12 14:51  健哥的数据花园  阅读(1567)  评论(0编辑  收藏  举报