Обсуждение: v11 transaction semantics inside procedures

Поиск
Список
Период
Сортировка

v11 transaction semantics inside procedures

От
Dave Cramer
Дата:
Is there somewhere that the transaction semantics inside a procedure are documented ? From what I can tell transactions start from the first DML statement and end implicitly when the procedure exits. Commit or Rollback can be called anytime inside the transaction and this implicitly starts another transaction.

Is there anything else I am missing ? Does DDL get applied after the transaction ends ?

I do find this somewhat surprising as Postgres typically requires a BEGIN statement to start a transaction block.

Thanks
Dave Cramer

Re: v11 transaction semantics inside procedures

От
Pavel Stehule
Дата:
Hi

čt 20. 9. 2018 v 17:55 odesílatel Dave Cramer <davecramer@gmail.com> napsal:
Is there somewhere that the transaction semantics inside a procedure are documented ? From what I can tell transactions start from the first DML statement and end implicitly when the procedure exits. Commit or Rollback can be called anytime inside the transaction and this implicitly starts another transaction.

Is there anything else I am missing ? Does DDL get applied after the transaction ends ?

The CALL statement starts possible chain of transactions. You can check pg_stat_activity - transaction is started by CALL command.
 

I do find this somewhat surprising as Postgres typically requires a BEGIN statement to start a transaction block.

When SELECT is not executed under explicitly started transactions, then transaction is started implicitly before execution of SELECT command.

There is different behave - SELECT is executed under only one transaction without exception. The procedure looks like client batch executed on server. It can be sequence of transactions.

Regards

Pavel


Thanks
Dave Cramer