pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: MauMau <maumau307@gmail.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
Cc: 'Simon Riggs' <simon@2ndquadrant.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] Statement-level rollback
Date: Sat, 16 Jun 2018 10:42:39 +0900
Message-ID: <A8377C6A188B4130A27E69851BF026BF@tunaPC> (raw)
In-Reply-To: <20180615202328.7m46qo46v5a5wkd2@alvherre.pgsql>
References: <20180615202328.7m46qo46v5a5wkd2@alvherre.pgsql>

From: Alvaro Herrera
> I've been looking at re-implementing this feature recently, using
> Tsunakawa's proposed UI of a GUC transaction_rollback_scope that can
> take values "transaction" (default, current behavior) and
"statement".
> I didn't take other parts of his patch though; see below.

Thank you so much for reviving this thread!


> I propose that we solve this by
> allowing this feature to be enabled only via one of:
>
> * a PGOPTIONS connection-time option
> * ALTER USER SET (transaction_rollback_scope)

Why don't we also allow ALTER DATABASE SET for a database exclusively
for data migrated from another DBMS?


> but it can be *disabled* normally via SET.  In other words, changing
the
> scope from transaction to statement in a running session is
forbidden,
> but changing it the other way around is allowed (if app is unsure
> whether env is unsafe, it can set the scope to "transaction" to
ensure
> it's safe from that point onwards).  Changing the scope in
> postgresql.conf is forbidden, so a server is never unsafe as a
whole.

Would it be dangerous to allow both enabling and disabling the
statement-level rollback only outside a transaction block?  I thought
it was considered dangerous to change the setting inside a transaction
block.


> Drivers such as JDBC can easily use this mode, for example a
connection
> option such as "AUTOSAVE=SERVER" can automatically add the
> transaction_rollback_scope option.  (Naturally, if the server does
not
> support transaction_rollback_scope and the user gave that option,
this
> causes an exception to be raised -- NOT to fallback to the standard
> transaction behavior!)

How do the drivers know, from the server error response to connection
request, that transaction_rollback_scope is unsupported?


> Tsunakawa's implementation puts the feature in postgres.c's client
loop.
> I think a better way to implement this is to change xact.c to have a
new
> TBLOCK state which indicates when to start a new internal
> subtransaction; StartTransactionCommand pushes a new element into
the
> transaction stack and puts it in the new state; a subsequent
operation
> actually starts the new subtransaction.  (This design decision
allows
> things like SAVEPOINT to work correctly by having the
> subtrasaction-for-savepoint appear *before* the internal
subtransaction,
> so a subsequent "SELECT 0/0" doesn't remove the user declared
> savepoint.)

That sounds interesting.

* How can PLs like PL/pgSQL utilize this to continue upon an SQL
failure?  They don't call StartTransactionCommand.

* How can psql make use of this feature for its ON_ERROR_ROLLBACK?


Regards
MauMau





view thread (52+ messages)  latest in thread

Message-ID: <A8377C6A188B4130A27E69851BF026BF@tunaPC>
Permalink:  ../A8377C6A188B4130A27E69851BF026BF@tunaPC/
Also on:    postgresql.org/message-id/A8377C6A188B4130A27E69851BF026BF@tunaPC

 · 

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-jdbc@postgresql.org
  Cc: maumau307@gmail.com, alvherre@2ndquadrant.com, tsunakawa.takay@jp.fujitsu.com, simon@2ndquadrant.com, peter.eisentraut@2ndquadrant.com, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] Statement-level rollback
  In-Reply-To: <A8377C6A188B4130A27E69851BF026BF@tunaPC>
  References: <20180615202328.7m46qo46v5a5wkd2@alvherre.pgsql> <A8377C6A188B4130A27E69851BF026BF@tunaPC>

* 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