Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZHS8j-0005qB-Dl for pgsql-bugs@arkaria.postgresql.org; Tue, 21 Jul 2015 07:39:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZHS8j-0005jn-04 for pgsql-bugs@arkaria.postgresql.org; Tue, 21 Jul 2015 07:39:01 +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) (envelope-from ) id 1ZHS8i-0005jh-M4 for pgsql-bugs@postgresql.org; Tue, 21 Jul 2015 07:39:00 +0000 Received: from hogranch.com ([75.101.82.47]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZHS8f-0001nQ-3Z for pgsql-bugs@postgresql.org; Tue, 21 Jul 2015 07:39:00 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id t6L7cmH10967; Tue, 21 Jul 2015 00:38:48 -0700 Subject: Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time To: dsrich@dsrich.net, pgsql-bugs@postgresql.org References: <20150721003929.9707.40340@wrigleys.postgresql.org> From: John R Pierce Message-ID: <55ADF703.60606@hogranch.com> Date: Tue, 21 Jul 2015 00:38:43 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150721003929.9707.40340@wrigleys.postgresql.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean X-Pg-Spam-Score: -3.1 (---) 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 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