pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John R Pierce <pierce@hogranch.com>
To: dsrich@dsrich.net
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time
Date: Tue, 21 Jul 2015 00:38:43 -0700
Message-ID: <55ADF703.60606@hogranch.com> (raw)
In-Reply-To: <20150721003929.9707.40340@wrigleys.postgresql.org>
References: <20150721003929.9707.40340@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 7/20/2015 5:39 PM, dsrich@dsrich.net wrote:
> Table:
>
> CREATE TABLE payees
> (
>    payeenum serial NOT NULL,
>    payeename character varying(127) NOT NULL,
>    remarks text,
>    CONSTRAINT payees_pkey PRIMARY KEY (payeenum),
>    CONSTRAINT payees_payeename_key UNIQUE (payeename)
> )
> WITH (
>    OIDS=FALSE
> );
> ALTER TABLE payees
>    OWNER TO dsrich;
> GRANT ALL ON TABLE payees TO dsrich;
> GRANT ALL ON TABLE payees TO users;
>
>
> Insert query:
>
> INSERT INTO payees (payeename, remarks) VALUES ('some string', 'some other
> string')
>
> This query (and three other versions  using DEFAULT and 'RETURNING payeenum'
> clauses) fails about half the time with payees_pkey constraint violation.
>
> There is nothing else going on in the database server, and the failure
> occurs both when the query comes through Npgsql (where I first saw this) and
> through pgAdmin.
>
> The same database has another table with the same basic structure that also
> has the same problem.
>

that basic sequence of operations sure seems to work for me,

$ psql
psql (9.3.9)
Type "help" for help.

pierce=# CREATE TABLE payees
pierce-# (
pierce(#   payeenum serial NOT NULL,
pierce(#   payeename character varying(127) NOT NULL,
pierce(#   remarks text,
pierce(#   CONSTRAINT payees_pkey PRIMARY KEY (payeenum),
pierce(#   CONSTRAINT payees_payeename_key UNIQUE (payeename)
pierce(# )
pierce-# WITH (
pierce(#   OIDS=FALSE
pierce(# );
CREATE TABLE
pierce=# INSERT INTO payees (payeename, remarks) VALUES ('some string', 
'some other
pierce'# string');
INSERT 0 1
pierce=# INSERT INTO payees (payeename, remarks) VALUES ('anohter 
string', 'some other
string');
INSERT 0 1
pierce=# INSERT INTO payees (payeename, remarks) VALUES ('yo dude', 
'some other
string');
INSERT 0 1

but I didn't mess about with your ALTER OWNER, GRANT as I ran all that 
from the same user.


when you create a column of pseudotype SERIAL, it creates a SEQUENCE.  
altering the table owner and granting users access, might not leave 
those users with rights to the sequence?



-- 
john r pierce, recycling bits in santa cruz



-- 
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 (3+ messages)  latest in thread

Message-ID: <55ADF703.60606@hogranch.com>
Permalink:  ../55ADF703.60606@hogranch.com/
Also on:    postgresql.org/message-id/55ADF703.60606@hogranch.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: pierce@hogranch.com, dsrich@dsrich.net
  Subject: Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time
  In-Reply-To: <55ADF703.60606@hogranch.com>
  References: <20150721003929.9707.40340@wrigleys.postgresql.org> <55ADF703.60606@hogranch.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