Can't setval() a sequence to return the first value

From: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Can't setval() a sequence to return the first value
Date: 2013-01-03 11:19:06
Message-ID: 50E5692A.7050309@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers.

Is it by design that you can't setval(seq, value) a sequence to a value
which returns the first value:

See the sample below for better explanation:

hannu=# create sequence s;
CREATE SEQUENCE
hannu=# select nextval('s');
nextval
---------
1
(1 row)
hannu=# select setval('s',1);
setval
--------
1
(1 row)
hannu=# select nextval('s');
nextval
---------
2
(1 row)
hannu=# select setval('s',0);
ERROR: setval: value 0 is out of bounds for sequence "s"
(1..9223372036854775807)

Should it not be possible to set sequence to one below the start value
so that you can completely reset it ?

--------------------
Hannu

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2013-01-03 11:23:19 Re: Can't setval() a sequence to return the first value
Previous Message Guillaume Lelarge 2013-01-03 10:56:31 Re: Behaviour of bgworker with SIGHUP