Re: documentation clarifications for "alter sequence" ?

Michael Paquier <[email protected]> Mon, 25 Nov 2019 13:01:08 +0900
Newsgroups gmane.comp.db.postgresql.devel.documentation
Message-ID <[email protected]>
On Thu, Nov 21, 2019 at 08:06:28PM +0000, PG Doc comments form wrote:
> -- it would be helpful if this interaction/ relation were explicitly pointed
> out, and why it behaves this way. ("MINVALUE cannot be greater than START
> value" makes more sense to me, since minvalue is the thing I'm attempting to
> alter. Or even "START value must be at least MINVALUE", if in fact that's
> the limitation.)

Project style is usually to avoid full sentences in user-facing error
messages, so an improvement may be something like that:
cannot set MINVALUE to be higher or equal than START value.

However, these error messages are actually as they are per the state
of the code, whose goal is to be kept simple.  If you look at
init_params() in sequence.c, what happens is that an initial state of
the sequence is taken, and then the parameters specified in *all* the
sub-clauses of the query update the state of the sequence.  Finally
all the parameters are cross-checked, so you cannot actually know
which parameter is being set.  Note that trying to guess what is
getting set and to inform that with more error messages would not be
that helpful either if trying to update both parameters at the same
time.  For example what would you do here?
ALTER SEQUENCE goo MINVALUE 4 START 1;


> --  "Any parameters not specifically set in the ALTER SEQUENCE command
> retain their prior settings". OK, but this does not seem intuitive, at least
> to me. What meaning or use does a min value have after a restart?

It simply means that non-updated parameters are left as they are
originally.  And minvalue/maxvalue are used depending on if the
sequence is ascending/descending if CYCLE is enabled.  If NO CYCLE is
used they are used as sanity checks.

> Also, "setval function" is mentioned. A link to that would be helpful.

You can say the same about currval, lastval and nextval, no?
--
Michael
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl3bUgQACgkQnvQgOdby
QH0tDg//R+WqU9iqyjupytDfFYiinol7Yh8uKDio2atr86KLFo1Io0gLqPvPZhMj
sGJQqDkYsmZrF3p3IM3ZvnyNhlGNAUn4Z+g1apj0goxvJ1LrsJn8hLR0X4LqzoMn
2s/nSsMHN0dsm7GlrLZhK6d9Dzhub5fMwFokqAwpReMMlV/09NG8J/8s7Qb3nEv9
z2gRDmewylNfAfARiKoA6rQ28CWAGjuOK5MwGjeztG+1lW6QfYHuQpcF7Q1+BrHF
erlQP5mKMxkeaUt03ObqQLReG7LwQBfWuoOHo+cpKExr13iiDWUEqybe25Bn0WSM
F2VP9UKh2aHNx+qn/YLjiSBakZW+Xqsk1o8ZvUQmvU5lQgQmiXhMfWQcqo3wA3jj
D6bKU3B2F7+aHoKSYqdhcGhIByn3JNaGOc5C+3UsRffBUOGIA/U9QPv3sdDqb2Qj
k7GJ03PxIjfcJreZ3Z5490QKfkTEe/ZLa2WW9tq4+YmY3JdjrSVaquSXR+cRA1j7
MJrwEazTq4yvaEUL53eCTiYnRdN4LxwhhWv7VoR2R/QyM9yK6lwOHaAdt4nQvLhG
rtwmiBVzaQSlFYKlefSLvdz5eKTMAurxxCT25fFxLb0CV24X9kRgJadtvD5+sNTW
dM7dLwhZlqf8qlw5v1bKlvbqMavxCM0jmAeRZz941qVvKKNCm8s=
=oQda
-----END PGP SIGNATURE-----