Skip site navigation (1) Skip section navigation (2)

Sequence/constraint bug

From: "Milo Hyson" <milo(at)cyberlifeservices(dot)com>
To: <bugs(at)postgresql(dot)org>
Subject: Sequence/constraint bug
Date: 2000-02-25 04:55:57
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
                        POSTGRESQL BUG REPORT TEMPLATE

Your name		: Milo Hyson
Your email address	: milo(at)cyberlifeservices(dot)com

System Configuration
  Architecture (example: Intel Pentium)  	: Intel Pentium Pro

  Operating System (example: Linux 2.0.26 ELF) 	: Linux 2.2.14 ELF

  PostgreSQL version (example: PostgreSQL-6.5.3):   PostgreSQL-6.5.3

  Compiler used (example:  gcc 2.8.0)		: egcs 1.1.2

Please enter a FULL description of your problem:

When inserting new rows into a table with a serial field, if a constraint
check fails, the sequence for the serial field is still incremented. As a
result you lose a number.

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:

1) CREATE TABLE dummy (id serial, other int4 NOT NULL CHECK(other <> 0));

2) INSERT INTO dummy (other) VALUES(1);

3) INSERT INTO dummy (other) VALUES(2);

4) INSERT INTO dummy (other) VALUES(0);

5) INSERT INTO dummy (other) VALUES(3);

6) SELECT * FROM dummy;

You'll see the following:

id other
-- -----
 1     1
 2     2
 4     3

pgsql-bugs by date

Next:From: Ralf TrefzDate: 2000-02-25 06:15:59
Subject: unsubscribe
Previous:From: Rolf GrossmannDate: 2000-02-25 01:07:13
Subject: Re: [HACKERS] Re: [BUGS] First experiences with Postgresql 7.0

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group