serial grows on failed requests

Started by rihadover 18 years ago2 messagesgeneral
Jump to latest
#1rihad
rihad@mail.ru

Hi, my table is defined as:
CREATE TABLE users (
id integer NOT NULL,
...
);

CREATE SEQUENCE users_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;

ALTER SEQUENCE users_id_seq OWNED BY users.id;

Although it's just a more verbose way to say
create table users (id serial primary key);
:)

When I do an insert that fails (like FK inconsistency, illegal value,
etc.) the users.id grows nonetheless... This is unacceptable for my
current needs. Any way to prevent that while still maintaining ease of
use? Using PostgreSQL 8.2.4

Thanks.

#2Andreas Kretschmer
akretschmer@spamfence.net
In reply to: rihad (#1)
Re: serial grows on failed requests

rihad <rihad@mail.ru> schrieb:

When I do an insert that fails (like FK inconsistency, illegal value, etc.)
the users.id grows nonetheless... This is unacceptable for my current

normal behavior.

needs. Any way to prevent that while still maintaining ease of use? Using
PostgreSQL 8.2.4

Look at:
http://www.varlena.com/GeneralBits/130.php

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknow)
Kaufbach, Saxony, Germany, Europe. N 51.05082�, E 13.56889�