aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2017-05-31 16:39:27 -0700
committerAndres Freund <andres@anarazel.de>2017-06-01 14:19:33 -0700
commit3d79013b970d4cc336c06eb77ed526b44308c03e (patch)
tree2565996996eb72029e8ba1658ee90c8b673fcfae /doc/src
parente9a3c047a5fc701d2efb776be2b351645ea001c8 (diff)
downloadpostgresql-3d79013b970d4cc336c06eb77ed526b44308c03e.tar.gz
postgresql-3d79013b970d4cc336c06eb77ed526b44308c03e.zip
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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/alter_sequence.sgml15
1 files changed, 7 insertions, 8 deletions
diff --git a/doc/src/sgml/ref/alter_sequence.sgml b/doc/src/sgml/ref/alter_sequence.sgml
index 30e5316b8cb..3a04d07ecc7 100644
--- a/doc/src/sgml/ref/alter_sequence.sgml
+++ b/doc/src/sgml/ref/alter_sequence.sgml
@@ -171,7 +171,7 @@ ALTER SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> S
<para>
The optional clause <literal>RESTART [ WITH <replaceable
class="parameter">restart</replaceable> ]</literal> changes the
- current value of the sequence. This is equivalent to calling the
+ current value of the sequence. This is similar to calling the
<function>setval</> function with <literal>is_called</literal> =
<literal>false</>: the specified value will be returned by the
<emphasis>next</> call of <function>nextval</>.
@@ -182,11 +182,11 @@ ALTER SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> S
</para>
<para>
- Like a <function>setval</function> call, a <literal>RESTART</literal>
- operation on a sequence is never rolled back, to avoid blocking of
- concurrent transactions that obtain numbers from the same sequence.
- (The other clauses cause ordinary catalog updates that can be rolled
- back.)
+ In contrast to a <function>setval</function> call,
+ a <literal>RESTART</literal> operation on a sequence is transactional
+ and blocks concurrent transactions from obtaining numbers from the
+ same sequence. If that's not the desired mode of
+ operation, <function>setval</> should be used.
</para>
</listitem>
</varlistentry>
@@ -307,8 +307,7 @@ ALTER SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> S
<para>
<command>ALTER SEQUENCE</command> blocks
concurrent <function>nextval</function>, <function>currval</function>,
- <function>lastval</function>, and <command>setval</command> calls, except
- if only the <literal>RESTART</literal> clause is used.
+ <function>lastval</function>, and <command>setval</command> calls.
</para>
<para>