BUG #15935: Auto increment column changes on error while inserting (violating unique constraint)

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: muhammadalinazarov(at)gmail(dot)com
Subject: BUG #15935: Auto increment column changes on error while inserting (violating unique constraint)
Date: 2019-07-31 11:30:06
Message-ID: 15935-20633f1e9fb4d69f@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15935
Logged by: Muhammadali Nazarov
Email address: muhammadalinazarov(at)gmail(dot)com
PostgreSQL version: 11.1
Operating system: Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86
Description:

I have seen one interesting behavior.
Let me show on example.

create table tmp (
id serial,
user_id int unique not null);

insert into tmp(user_id)
select 1;

our id => 1, autoincrement value 2;
insert into tmp(user_id)
select 1;

violating unique constraint, autoincrement value 3;
insert into tmp(user_id)
select 2;

select id, user_id
from tmp;
id | user_id
----+---------
1 | 1
3 | 2

Is this a bug or no?
Thank you for your attention.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Raymond 2019-07-31 13:36:11 RE: BUG #15935: Auto increment column changes on error while inserting (violating unique constraint)
Previous Message PG Bug reporting form 2019-07-31 10:12:25 BUG #15934: pg_dump output in wrong order if custom operator class is used as subtype_opclass in a range type