Re: documentation clarifications for "alter sequence" ?
От | Michael Paquier |
---|---|
Тема | Re: documentation clarifications for "alter sequence" ? |
Дата | |
Msg-id | 20191125040108.GI37821@paquier.xyz обсуждение исходный текст |
Ответ на | documentation clarifications for "alter sequence" ? (PG Doc comments form <noreply@postgresql.org>) |
Список | 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
Вложения
В списке pgsql-docs по дате отправления: