且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为PostgreSQL存储过程设置隔离级别

更新时间:2022-12-17 19:32:22

您不能这样做。

您可以做的是让您的函数检查当前的事务隔离级别并中止。如果不是您想要的那个。您可以通过运行 SELECT current_setting('transaction_isolation')然后检查结果来完成此操作。

What you could do is have your function check what the current transaction isolation level is and abort if it's not the one you want. You can do this by running SELECT current_setting('transaction_isolation') and then checking the result.