是否有可以从查询中写入文件的 PostgreSQL function/keyword?

Is there a PostgreSQL function/keyword that can write to a file from within queries?

我记得以前用MySQL的时候,MySQL有一个功能可以让你向系统文件写入任何你想要的东西。事实上,这是将后门 shell 上传到服务器的多种方式之一。

无论如何,我想做的是在 PostgreSQLtable 中创建一个 AFTER INSERT 触发器,它将使用另一个进程将一些行的信息写入 file/pipe在另一个端点上监听。

我希望它的行为类似于消息队列,但不使用代理。

是否有这样的 SQL 函数(标准或自定义)可以让我实现这一点?

谢谢

是的,Postgres can be extended in a variety of programming languages with C, Python, Perl, and TCL available out of the box. From there you can do whatever you like. You might take some hints from various replication systems, in particular Slony 是基于触发器的。