磨砺技術珠矶,踐行資料之道,追求卓越價值
回到上一級頁面: PostgreSQL基礎知識與基本操作索引頁 回到頂級頁面:PostgreSQL索引頁
接PostgreSQL的notify 與listen (六)的内容,探讨一下誰真正接受notify 消息。
修改PostgreSQL的源代碼:src/backend/command/async.c:
NotifyMyFrontEnd(const char *channel, const char *payload, int32 srcPid)函數
啟動 postgres, 執行 ps -ef|grep postgres
再來看 ps -ef|grep postgre: 程序号27764/父程序号27695的 名為postgres的程序已啟動。
再來看 ps -ef|grep postgre: 程序号27857/父程序号27695 的 名為postgres的程序已啟動。
再回到session A, 随便執行一條指令:
這表明 資訊的發送者實際上是 和notify 端對應的 背景postgres程序。資訊的接受者首先也是和listen端對應的背景postgres程序,由此程序把消息推送給 前台psql(listen端)。