v11 transaction semantics inside procedures

Started by Dave Cramerover 7 years ago2 messages
#1Dave Cramer
davecramer@gmail.com

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

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Dave Cramer (#1)
Re: v11 transaction semantics inside procedures

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

Show quoted text

Thanks
Dave Cramer