Re: v11 transaction semantics inside procedures - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: v11 transaction semantics inside procedures
Date
Msg-id CAFj8pRAJacSkFD=5a5i0hy-2G3F5cmmm0Fd7mdYiFYoVN4bV-g@mail.gmail.com
Whole thread Raw
In response to v11 transaction semantics inside procedures  (Dave Cramer <davecramer@gmail.com>)
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: generating bootstrap entries for array types
Next
From: ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Date:
Subject: Re: generating bootstrap entries for array types