Re: documentation clarifications for "alter sequence" ?

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: mickey(at)thesweetoasis(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: documentation clarifications for "alter sequence" ?
Date: 2019-11-25 04:01:08
Message-ID: 20191125040108.GI37821@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Michael Paquier 2019-11-25 07:55:07 Re: Add A Glossary
Previous Message Michael Paquier 2019-11-25 01:20:36 Re: monitoring-stats.html is too impenetrable