pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: zam6ak@gmail.com
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #14756: Inserting row with PK IDENTITY column fails 1st time
Date: Wed, 2 Aug 2017 14:22:55 -0400
Message-ID: <0ddc33be-4961-673e-331f-9e98a37f3f79@2ndquadrant.com> (raw)
In-Reply-To: <20170724012517.1455.83097@wrigleys.postgresql.org>
References: <20170724012517.1455.83097@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 7/23/17 21:25, zam6ak@gmail.com wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      14756
> Logged by:          zam zam
> Email address:      zam6ak@gmail.com
> PostgreSQL version: 10beta2
> Operating system:   docker for windows 17.06 ce
> Description:        
> 
> - table with PK IDENTITY COLUMN
> - insert 1st row and specify PK value (OVERRIDING)
> - insert 2nd row using defaults (fails)
> - try same command again (succeeds)
> 
> The failure is only on the 1st attempt.

This is working correctly, AFAICT.  When you insert an explicit value
into the identity column, the sequence is not advanced.

> -- but now, neither of these works ("ERROR:  duplicate key value violates
> unique constraint "audit_pk"")
> -- THEY ONLY DON"T WORK 1st TIME you try (either statement), 
> -- on 2nd attept each succeeds (My guess 1st time sequence is
> updated/corrected so 2nd time it goes through)

That is correctly observed.

> INSERT INTO public.audit VALUES (DEFAULT, 'public.audit'::regclass,
> 'public', 'audit');
> INSERT INTO public.audit (relation_id, schema_name, table_name) VALUES
> ('public.audit'::regclass, 'public', 'audit');
-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <0ddc33be-4961-673e-331f-9e98a37f3f79@2ndquadrant.com>
Permalink:  ../0ddc33be-4961-673e-331f-9e98a37f3f79@2ndquadrant.com/
Also on:    postgresql.org/message-id/0ddc33be-4961-673e-331f-9e98a37f3f79@2ndquadrant.com

 · 

reply

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: peter.eisentraut@2ndquadrant.com, zam6ak@gmail.com
  Subject: Re: BUG #14756: Inserting row with PK IDENTITY column fails 1st time
  In-Reply-To: <0ddc33be-4961-673e-331f-9e98a37f3f79@2ndquadrant.com>
  References: <20170724012517.1455.83097@wrigleys.postgresql.org> <0ddc33be-4961-673e-331f-9e98a37f3f79@2ndquadrant.com>

* 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