1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Adjust min/max values when changing sequence type

When changing the type of a sequence, adjust the min/max values of the
sequence if it looks like the previous values were the default values.
Previously, it would leave the old values in place, requiring manual
adjustments even in the usual/default cases.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
Reviewed-by: Vitaly Burovoy <vitaly.burovoy@gmail.com>
This commit is contained in:
Peter Eisentraut
2017-04-04 12:36:15 -04:00
parent a9a7949134
commit 60a0b2ec89
4 changed files with 96 additions and 22 deletions

View File

@ -94,10 +94,15 @@ ALTER SEQUENCE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> S
</para>
<para>
Note that changing the data type does not automatically change the
minimum and maximum values. You can use the clauses <literal>NO
MINVALUE</literal> and <literal>NO MAXVALUE</literal> to adjust the
minimum and maximum values to the range of the new data type.
Changing the data type automatically changes the minimum and maximum
values of the sequence if and only if the previous minimum and maximum
values were the minimum or maximum value of the old data type (in
other words, if the sequence had been created using <literal>NO
MINVALUE</literal> or <literal>NO MAXVALUE</literal>, implicitly or
explicitly). Otherwise, the minimum and maximum values are preserved,
unless new values are given as part of the same command. If the
minimum and maximum values do not fit into the new data type, an error
will be generated.
</para>
</listitem>
</varlistentry>