From: cwire4@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14126: INSERT ON CONFLICT DO NOTHING auto increments serial primary key when no insert happens.
Date: Fri, 06 May 2016 06:55:28 +0000
Message-ID: <20160506065528.2693.64808@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14126
Logged by: Casey Wireman
Email address: cwire4@gmail.com
PostgreSQL version: 9.5.2
Operating system: Windows 7
Description:
It's unclear to me if this is desired behavior or not, but when doing the
following:
insert into table(column) values (value) on conflict DO NOTHING
the first time a new entry is inserted it works as expected and
autoincrements the serial primary key as normal, however if I try to insert
this again the on conflict correctly detects that the value already exists,
but internally seems to autoincrement the serial key as many times as you
try to do the failed insert since on the next insert of a new value the key
value is
(previous successful key value + number of failed inserts)
It seems to me that intuitively the key should only increment on a
successful insert, not just an insert statement being executed. For one,
this unnecessarily reduces the keyspace available for the column.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: cwire4@gmail.com
Subject: Re: BUG #14126: INSERT ON CONFLICT DO NOTHING auto increments serial primary key when no insert happens.
In-Reply-To: <20160506065528.2693.64808@wrigleys.postgresql.org>
References: <20160506065528.2693.64808@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox