Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aycKV-00044h-4P for pgsql-bugs@arkaria.postgresql.org; Fri, 06 May 2016 09:45:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aycKU-0005hn-It for pgsql-bugs@arkaria.postgresql.org; Fri, 06 May 2016 09:45:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ayZgC-0007ex-Hw for pgsql-bugs@postgresql.org; Fri, 06 May 2016 06:56:04 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ayZgA-0002qA-JA for pgsql-bugs@postgresql.org; Fri, 06 May 2016 06:56:04 +0000 MIME-Version: 1.0 Subject: BUG #14126: INSERT ON CONFLICT DO NOTHING auto increments serial primary key when no insert happens. To: pgsql-bugs@postgresql.org From: cwire4@gmail.com Date: Fri, 06 May 2016 06:55:28 +0000 Message-ID: <20160506065528.2693.64808@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.1 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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