From: | Doug McNaught <doug(at)wireboard(dot)com> |
---|---|
To: | Rasmus Resen Amossen <NOSPAM(at)hey(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Bug? |
Date: | 2001-11-15 15:24:04 |
Message-ID: | m33d3gcb1n.fsf@belphigor.mcnaught.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Rasmus Resen Amossen <NOSPAM(at)hey(dot)com> writes:
> CREATE TABLE test (
> id SERIAL NOT NULL,
> val INT
> );
>
> The the following insertions creates an error:
> INSERT INTO test(id,val) VALUES (1,1);
> INSERT INTO test(val) VALUES (1);
>
> Error:
> Cannot insert a duplicate key into unique index test_id_key
>
> After that I can just reåeat the second line and insert without errors.
> Is this bug fixed in newer versions?
Not a bug. The second insert of the two above increments the SERIAL
sequence for 'id', and the incremented value is the same as the one
you explicitly inserted earlier. Since SERIAL columns have a unique
index on them, the insert fails.
When you repeat the second insert, the sequence is incremented again,
and this time it doesn't collide.
-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863
From | Date | Subject | |
---|---|---|---|
Next Message | Vince Vielhaber | 2001-11-15 15:35:04 | Re: Postgres+Delphi |
Previous Message | Vivek Khera | 2001-11-15 15:05:22 | Re: Modifying check constraints |