3

I know that postgreSQL locks a row while he is doing a function because of transaction process. So I tried to trigger a function when the last row of the table was unlock.

Let's take an example:

function_one() and function_two are defined inside PG.

My application use function_one() to add data or update some stuff whatever. When it's done, the last row needed is unlock and I can do an launch an other transaction if I want. So at this point I want postgreSQL to launch function_two() when function_one() is done.

Thanks for answer(s).

EDIT : More informations

I have already tried to put a trigger on a PG catalog but it did not work because I had the information I needed thanks to a view and you can't trigger data of a view.

4

2 回答 2

1

因此,要释放锁,您需要执行以下命令之一:

commit;
rollback;

因此,如果您有这样的代码:

function_one();
commit;    
function_two();

那将是您正在寻找的。本质上,问题在于以这样一种方式链接您的函数,即您决定何时释放锁。

于 2013-07-17T15:29:03.243 回答
0

根据您的语言,您可能希望使用任何可用的异步 API。这在 PHP、Perl 和许多其他语言中都可用,但这是客户端问题,而不是服务器问题。

本质上,由客户端决定是否等待函数返回。

于 2013-10-29T13:30:35.930 回答