pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Nikander <rob.nikander@gmail.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: procedures and transactions
Date: Tue, 19 Feb 2019 15:48:00 -0600
Message-ID: <72DE4DF2-7013-4D03-AD28-426BFD1B78A0@gmail.com> (raw)
In-Reply-To: <CAKFQuwYdbkOv3HAGo=heMDQB9zs5_31mK2FR05sYVHXmq4u+Pg@mail.gmail.com>
References: <FB0D74E9-6CAE-4FDD-BAD6-8AA31169F363@gmail.com>
	<CAKFQuwYdbkOv3HAGo=heMDQB9zs5_31mK2FR05sYVHXmq4u+Pg@mail.gmail.com>

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 <mailto:rob.nikander@gmail.com>> wrote:
>  Are procedures not allowed to commit/rollback if they are called within in an outer transaction?
> 
>  https://www.postgresql.org/docs/11/sql-call.html <https://www.postgresql.org/docs/11/sql-call.html;
> 
> 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?
> 
>  https://www.postgresql.org/docs/11/plpgsql-transactions.html <https://www.postgresql.org/docs/11/plpgsql-transactions.html;
> 
> David J.
> 

view thread (8+ messages)  latest in thread

Message-ID: <72DE4DF2-7013-4D03-AD28-426BFD1B78A0@gmail.com>
Permalink:  ../72DE4DF2-7013-4D03-AD28-426BFD1B78A0@gmail.com/
Also on:    postgresql.org/message-id/72DE4DF2-7013-4D03-AD28-426BFD1B78A0@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: rob.nikander@gmail.com
  Subject: Re: procedures and transactions
  In-Reply-To: <72DE4DF2-7013-4D03-AD28-426BFD1B78A0@gmail.com>
  References: <FB0D74E9-6CAE-4FDD-BAD6-8AA31169F363@gmail.com> <CAKFQuwYdbkOv3HAGo=heMDQB9zs5_31mK2FR05sYVHXmq4u+Pg@mail.gmail.com> <72DE4DF2-7013-4D03-AD28-426BFD1B78A0@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox