The following bug has been logged online:
Bug reference: 1127
Logged by: Piotr Konieczny
Email address: znahor@vix.netsync.pl
PostgreSQL version: 7.4
Operating system: Linux
Description: ALTER SEQUENCE bug
Details:
ALTER SEQUENCE doesn't work properly, when only first value has been readed
from sequence:
test=# create TABLE t (s serial, t text);
NOTICE: CREATE TABLE will create implicit sequence "t_s_seq" for "serial"
column "t.s"
NOTICE: CREATE TABLE will create implicit sequence "t_s_seq" for "serial"
column "t.s"
CREATE TABLE
test=# insert into t (t) VALUES ('1');
INSERT 17151 1
test=# select * from t;
s | t
---+---
1 | 1
(1 row)
test=# delete from t;
DELETE 1
test=# ALTER sequence t_s_seq restart 1;
ALTER SEQUENCE
test=# insert into t (t) VALUES ('1');
INSERT 17152 1
test=# select * from t;
s | t
---+---
2 | 1
(1 row)
test=# delete from t;
DELETE 1
test=# ALTER sequence t_s_seq restart 1;
ALTER SEQUENCE
test=# insert into t (t) VALUES ('1');
INSERT 17153 1
test=# select * from t;
s | t
---+---
1 | 1
(1 row)
test=#