postgresql - 在 psql 客户端中使用 LISTEN/NOTIFY

标签 postgresql ipc psql

我通过 psql 客户端连接到在 Docker 容器中运行的同一个数据库服务器。

  1. 在客户端 A 中,我运行 listen "virtual";
  2. 在客户端 B 中,我运行 notify "virtual";

我希望在客户端 A 中看到它收到异步通知的某种输出。

psql客户端可以这样用吗?

最佳答案

通知仅作为请求的有效负载从服务器检索。如果客户端没有向服务器发送请求,它就不会看到通知。

psql 中,你可以运行一个空语句(只有一个 ;)来做到这一点:

someuser=> ;
Asynchronous notification "virtual" received from server process with PID 11284.
someuser=>

关于postgresql - 在 psql 客户端中使用 LISTEN/NOTIFY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60487809/

相关文章:

postgresql - Postgres : Which is the order execution of triggers that are specified for different releations but activated by the same event?

postgresql - 如何在 psql 控制台中打印当前工作目录?

postgresql - 如果我将某些表的 autovacuum 比例因子设置为零,会对数据库产生不利影响吗?

windows - 在 Windows 上的 R 中执行 PSQL

Postgresql 分区表删除触发器失败

sql - 删除 SQL 结果中的 SUM 列

sql - 按其他列的特定规则选择行值对

c++ - CreateRemoteThread、LoadLibrary 和 PostThreadMessage。什么是正确的 IPC 方法?

c - fgetc 阻塞 : problem with reading from a pipe

unix - Unix FIFO/命名管道的命名约定是什么?