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索引页
磨砺技术珠矶,践行数据之道,追求卓越价值
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步