pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@postgresql.org
Subject: pgsql: Make ALTER SEQUENCE, including RESTART, fully transactional.
Date: Thu, 01 Jun 2017 21:22:46 +0000
Message-ID: <E1dGXYM-0001wP-3i@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Make ALTER SEQUENCE, including RESTART, fully transactional.

Previously the changes to the "data" part of the sequence, i.e. the
one containing the current value, were not transactional, whereas the
definition, including minimum and maximum value were.  That leads to
odd behaviour if a schema change is rolled back, with the potential
that out-of-bound sequence values can be returned.

To avoid the issue create a new relfilenode fork whenever ALTER
SEQUENCE is executed, similar to how TRUNCATE ... RESTART IDENTITY
already is already handled.

This commit also makes ALTER SEQUENCE RESTART transactional, as it
seems to be too confusing to have some forms of ALTER SEQUENCE behave
transactionally, some forms not.  This way setval() and nextval() are
not transactional, but DDL is, which seems to make sense.

This commit also rolls back parts of the changes made in 3d092fe540
and f8dc1985f as they're now not needed anymore.

Author: Andres Freund
Discussion: https://postgr.es/m/20170522154227.nvafbsm62sjpbxvd@alap3.anarazel.de
Backpatch: Bug is in master/v10 only

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3d79013b970d4cc336c06eb77ed526b44308c03e

Modified Files
--------------
doc/src/sgml/ref/alter_sequence.sgml         |  15 ++--
src/backend/commands/sequence.c              | 123 +++++++--------------------
src/test/isolation/expected/sequence-ddl.out |  30 +++----
src/test/isolation/specs/sequence-ddl.spec   |  19 +++--
4 files changed, 65 insertions(+), 122 deletions(-)


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


Message-ID: <E1dGXYM-0001wP-3i@gemulon.postgresql.org>
Permalink:  ../E1dGXYM-0001wP-3i@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1dGXYM-0001wP-3i@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: pgsql: Make ALTER SEQUENCE, including RESTART, fully transactional.
  In-Reply-To: <E1dGXYM-0001wP-3i@gemulon.postgresql.org>
  References: <E1dGXYM-0001wP-3i@gemulon.postgresql.org>

* 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