[HACKERS] Statement-level rollback - Mailing list pgsql-hackers

From Tsunakawa, Takayuki
Subject [HACKERS] Statement-level rollback
Date
Msg-id 0A3221C70F24FB45833433255569204D1F6A9286@G01JPEXMBYT05
Whole thread Raw
Responses Re: [HACKERS] Statement-level rollback  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] Statement-level rollback  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Re: [HACKERS] Statement-level rollback  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
Hello,

As I stated here and at the PGConf.ASIA developer meeting last year, I'd like to propose statement-level rollback
feature. To repeat myself, this is requested for users to migrate from other DBMSs to PostgreSQL.  They expect that a
failureof one SQL statement should not abort the entire transaction and their apps (client programs and stored
procedures)can continue the transaction with a different SQL statement.
 


SPECIFICATION
==================================================

START TRANSACTION ROLLBACK SCOPE { TRANSACTION | STATEMENT };

This syntax controls the behavior of the transaction when an SQL statement fails.  TRANSACTION (default) is the
traditionalbehavior (i.e. rolls back the entire transaction or subtransaction).  STATEMENT rolls back the failed SQL
statement.

Just like the isolation level and access mode, default_transaction_rollback_scope GUC variable is also available.


DESIGN
==================================================

Nothing much to talk about... it merely creates a savepoint before each statement execution and destroys it after the
statementfinishes.  This is done in postgres.c for top-level SQL statements.
 

The stored function hasn't been handled yet; I'll submit the revised patch soon.


CONSIDERATIONS AND REQUESTS
==================================================

The code for stored functions is not written yet, but I'd like your feedback for the specification and design based on
thecurrent patch.  I'll add this patch to CommitFest 2017-3.
 

The patch creates and destroys a savepoint for each message of the extended query protocol (Parse, Bind, Execute and
Describe). I'm afraid this will add significant overhead, but I don't find a better way, because those messages could
besend arbitrarily for different statements, e.g. Parse stmt1, Parse stmt2, Bind stmt1, Execute stmt1, Bind stmt2,
Executestmt2.
 


Regards
Takayuki Tsunakawa


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: [HACKERS] IF (NOT) EXISTS in psql-completion
Next
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] Report the number of skipped frozen pages by manual VACUUM