Re: procedures and transactions - Mailing list pgsql-general

From Rob Nikander
Subject Re: procedures and transactions
Date
Msg-id 72DE4DF2-7013-4D03-AD28-426BFD1B78A0@gmail.com
Whole thread Raw
In response to Re: procedures and transactions  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: procedures and transactions  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: procedures and transactions  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-general
I thought if I had some application logic that needed a certain kind of transaction (maybe a non-default isolation level), I could hide that fact in a procedure. App code (Java/Python/whatever) could remain unaware of transactions (except maybe needing to retry after a failure) and simply send `call foo(?, ?)` to the DB. But maybe that kind of design is not supported, and application code needs to start transactions and set isolation levels. Is that accurate?  I supposed a procedure could throw an exception if it doesn’t like the value in `current_setting('transaction_isolation’)`.

Rob

On Feb 19, 2019, at 2:38 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:

On Tuesday, February 19, 2019, Rob Nikander <rob.nikander@gmail.com> wrote:
 Are procedures not allowed to commit/rollback if they are called within in an outer transaction?


Also, I tried putting a `start transaction` command in the procedure. I got another error: `unsupported transaction command in PL/pgSQL`. Are procedures not allowed to start transactions? Or is there another command?


David J.


pgsql-general by date:

Previous
From: Samuel Williams
Date:
Subject: Re: Partial index on JSON column
Next
From: Adrian Klaver
Date:
Subject: Re: procedures and transactions