X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 20015528AA for ; Sat, 18 Jun 2005 10:53:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65954-08 for ; Sat, 18 Jun 2005 13:52:57 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 8241852896 for ; Sat, 18 Jun 2005 10:52:55 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j5IDqtcH071363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 18 Jun 2005 07:52:58 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j5IDqtKS091565; Sat, 18 Jun 2005 07:52:55 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j5IDqtNw091564; Sat, 18 Jun 2005 07:52:55 -0600 (MDT) (envelope-from mfuhr) Date: Sat, 18 Jun 2005 07:52:55 -0600 From: Michael Fuhr To: "Hortschitz, Stefan" Cc: pgsql-admin@postgresql.org Subject: Re: failed insert into serial-type row Message-ID: <20050618135255.GA91505@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/146 X-Sequence-Number: 17901 On Tue, Jun 14, 2005 at 07:28:22AM +0200, Hortschitz, Stefan wrote: > > sometimes if i'm adding new rows to the table with statements like > this: > > insert into (name,value) ('xy','xy'); > > the database only returns an 'duplicate key on primary key', which > should be prevented by the serial-datatype, or? how could it be, that > two rows become the same id?? One possibility is that the table contains IDs that are higher than the sequence value, so you occasionally get duplicates when you use the sequence. What are the results of the following queries? SELECT max(id) FROM session.preferences; SELECT * FROM session.preferences_id_seq; If max(id) is higher than the sequence's last_value, then you can adjust the sequence with setval() or ALTER SEQUENCE. Then you should to figure out how that happened so you can prevent it from happening again. -- Michael Fuhr http://www.fuhr.org/~mfuhr/