磨砺技術珠矶,踐行資料之道,追求卓越價值
回到上一級頁面: 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#commit;
COMMIT
收到 來自伺服器 "event01" 程序PID 5558 非同步通知
回到上文:PostgreSQL的notify 與listen (一)
磨砺技術珠矶,踐行資料之道,追求卓越價值