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: 200002250459.XAA67219@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

Browse pgsql-bugs by date

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