Issue 10235

Crash trying to set sequence's number_next to zero
Nosy list
albertca, ced, reviewbot
Assigned to

Created on 2021-03-29.19:48:29 by albertca, last changed 1 week ago by ced.


Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-03-29.23:26:19

I do not think so. This is as much arbitrary as the postgresql default. More over it still do not prevent to have similar error for out of the range value. Also database administrator could any way customize the value of a sequence.

Author: [hidden] (albertca) Tryton committer
Date: 2021-03-29.22:14:59

I think it would be better to set MINVALUE to -9223372036854775808 in:

As sequence is a BIGINT by default, -9223372036854775808 is its minimum value:

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-03-29.20:26:12

I think a good solution would be to catch the error from the backend and raise a UserError with a proper message.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-03-29.20:16:45

For me it is specificity of the backend, I do not think we should do anything against that.

Author: [hidden] (albertca) Tryton committer
Date: 2021-03-29.19:48:29

Trying to set number_next to 0 or lower will cause the following crash:

Traceback (most recent call last):
  File "/trytond/", line 114, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/", line 48, in rpc
    request, database_name, *request.rpc_params)
  File "/trytond/", line 81, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/", line 186, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/ir/", line 184, in write
  File "/trytond/ir/", line 264, in update_sql_sequence
    self._sql_sequence_name, self.number_increment, number_next)
  File "/trytond/backend/postgresql/", line 500, in sequence_update
    (number_increment, start_value))
  File "/trytond/backend/postgresql/", line 68, in execute
    cursor.execute(self, sql, args)
psycopg2.errors.InvalidParameterValue: RESTART value (0) cannot be less than MINVALUE (1)
Date User Action Args
2021-03-29 23:26:19cedsetmessages: + msg65926
2021-03-29 22:14:59albertcasetmessages: + msg65925
2021-03-29 20:26:12cedsetmessages: + msg65924
2021-03-29 20:18:06reviewbotsetmessages: + msg65923
nosy: + reviewbot
2021-03-29 20:16:45cedsetmessages: + msg65922
nosy: + ced
2021-03-29 19:55:46albertcasetstatus: unread -> testing
2021-03-29 19:55:34albertcasetkeyword: + review
reviews: 357601005
2021-03-29 19:48:29albertcacreate

Showing 10 items. Show all history (warning: this could be VERY long)