Postgresql 中文操作指南

41.6. Rules and Command Status #

PostgreSQL 服务器返回一条命令状态字符串,例如 INSERT 149592 1,以用于它接收的每条命令。如果没有涉及任何规则,这是非常简单的,但是当该查询被规则重新编写时会发生什么呢?

The PostgreSQL server returns a command status string, such as INSERT 149592 1, for each command it receives. This is simple enough when there are no rules involved, but what happens when the query is rewritten by rules?

规则会影响如下命令状态:

Rules affect the command status as follows:

程序员可以通过提供活动规则中最靠后的规则名称,从而确保任何所需的 INSTEAD 规则是在第二情况下设置命令状态的规则,以便它能够最后被应用。

The programmer can ensure that any desired INSTEAD rule is the one that sets the command status in the second case, by giving it the alphabetically last rule name among the active rules, so that it gets applied last.