Re: [BUGS] BUG #14756: Inserting row with PK IDENTITY column fails1st time - Mailing list pgsql-bugs

From Peter Eisentraut
Subject Re: [BUGS] BUG #14756: Inserting row with PK IDENTITY column fails1st time
Date
Msg-id 0ddc33be-4961-673e-331f-9e98a37f3f79@2ndquadrant.com
Whole thread Raw
In response to [BUGS] BUG #14756: Inserting row with PK IDENTITY column fails 1st time  (zam6ak@gmail.com)
List pgsql-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

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] Re: [BUGS] BUG #14758: Segfault with logicalreplication on a function index
Next
From: Peter Geoghegan
Date:
Subject: Re: [BUGS] Crash report for some ICU-52 (debian8) COLLATE andwork_mem values